SlideShare une entreprise Scribd logo
1  sur  17
Télécharger pour lire hors ligne
CocoaHeads
14 Mai 2013
mardi 28 mai 13
Backelite...
...recrute !mardi 28 mai 13
Au programme
• Accessors Vs Direct access to properties
• Design Pattern : Categories
• Design Pattern : Associative Storage
• La chaine Météo!
mardi 28 mai 13
iVar : Accessors/Direct access
• Performance ?
• Risks / Limits ?
mardi 28 mai 13
property Using setter (ms)
Using Direct Access
(ms)
strong + nonatomic 9 6
weak + nonatomic 30 30
unsafe_unretained +
nonatomic
0,8 0,2
strong + atomic 9 6
iPhone 3GS/iOS5 + 10,000 affectactions. (average based
on several tests.)
iVar : Accessors/Direct access
Performance?
mardi 28 mai 13
• Direct affectation don’t use the property
attributes (atomic)
• KVO/KVC needs accessors,
• Don’t use accessor methods in init methods
and dealloc (You may have override your
accessors)
iVar : Accessors/Direct access
Risk / Limits?
mardi 28 mai 13
Design Pattern: Categories
• Add new methods to existing classes
#import "IBSHelper.h"
@interface IBSHelper (FileName)
+ (NSString*)filenameForGeolocData;
+ (NSString*)filenameForBrandCodeData;
+ (NSString*)filenameForTradData;
+ (NSString *)currentLanguage;
+ (NSString *)currentLanguageForDownload;
+ (NSURL*)urlForGeolocData;
+ (NSURL*)urlForBrandData;
+ (NSURL*)urlForTradData;
@end
mardi 28 mai 13
Design Pattern: Categories
• Organize/split complexity
mardi 28 mai 13
Design Pattern: Categories
• Makes easy to support multiple OS versions
@interface UITableView (BkUICore)
- (void) bkRegisterNibName:(NSString *)nibName forCellReuseIdentifier:
(NSString *)identifier;
- (id) bkDequeueReusableCellWithIdentifier:(NSString *)identifier;
@end
@interface UIViewController (BkUICore)
- (void) bkDismissModalViewControllerAnimated:(BOOL)animated;
- (void) bkPresentViewController:(UIViewController *)controller
animated:(BOOL)animated;
@end
mardi 28 mai 13
Design Pattern: Categories
• Categories can be used to declare either instance
methods or class methods but are not usually
suitable for declaring additional properties.
One other design pattern can help us !
Associated storage
@interface UITableView (BkUICore)
- (void) bkRegisterNibName:(NSString *)nibName forCellReuseIdentifier:
(NSString *)identifier;
- (id) bkDequeueReusableCellWithIdentifier:(NSString *)identifier;
@end
mardi 28 mai 13
Design Pattern: Associative references
http://developer.apple.com/library/mac/#documentation/
Cocoa/Conceptual/ObjCRuntimeGuide/Introduction/
Introduction.html#//apple_ref/doc/uid/TP40008048
Objective-C programs interact with the runtime system at three distinct
levels: through Objective-C source code; through methods defined in the
NSObject class of the Foundation framework; and through direct calls to
runtime functions.
mardi 28 mai 13
Design Pattern: Associative references
//nsobjet.h
@interface NSObject
+ (Class)superclass;
+ (Class)class;
- (BOOL)respondsToSelector:(SEL)aSelector;
+ (BOOL)conformsToProtocol:(Protocol *)protocol;
//runtime.h
OBJC_EXPORT Class class_getSuperclass(Class cls)
OBJC_EXPORT Class object_getClass(id obj)
OBJC_EXPORT BOOL class_respondsToSelector(Class cls, SEL sel)
OBJC_EXPORT BOOL class_conformsToProtocol(Class cls, Protocol *protocol)
Some of the NSObject methods simply query the runtime system for information.
These methods allow objects to perform introspection.
mardi 28 mai 13
• A way to add simulate new properties to an
existing class !
Design Pattern: Associative references
static const char nibsAssocKey;
@implementation UITableView (BkUICore)
- (void) bkRegisterNibName:(NSString *)nibName forCellReuseIdentifier:(NSString
*)identifier
{
if ([self respondsToSelector:@selector(registerNib:forCellReuseIdentifier:)]) {
[self registerNib:[UINib nibWithNibName:nibName bundle:[NSBundle mainBundle]]
forCellReuseIdentifier:identifier]; //NS_AVAILABLE_IOS(5_0)
} else {
NSMutableDictionary *nibs = objc_getAssociatedObject(self, &nibsAssocKey);
if (nil == nibs) {
nibs = [NSMutableDictionary dictionary];
objc_setAssociatedObject(self, &nibsAssocKey,
nibs, OBJC_ASSOCIATION_RETAIN);
}
[nibs setValue:nibName forKey:identifier];
}
}
@end
mardi 28 mai 13
La chaine meteo
Issue : How to add a new property on UINavigationBar
• Subclass UINavigationBar, dumbass !
• Use associated storage !
mardi 28 mai 13
La chaine meteo
mardi 28 mai 13
Other examples
• UIView + BkBadge
• UIView + BkLoader
....
mardi 28 mai 13
Thanks
mardi 28 mai 13

Contenu connexe

Tendances

Deploy your app with one Slack command
Deploy your app with one Slack commandDeploy your app with one Slack command
Deploy your app with one Slack commandFabio Milano
 
Build a lego app with CocoaPods
Build a lego app with CocoaPodsBuild a lego app with CocoaPods
Build a lego app with CocoaPodsCocoaHeads France
 
"I have a framework idea" - Repeat less, share more.
"I have a framework idea" - Repeat less, share more."I have a framework idea" - Repeat less, share more.
"I have a framework idea" - Repeat less, share more.Fabio Milano
 
Apache ANT vs Apache Maven
Apache ANT vs Apache MavenApache ANT vs Apache Maven
Apache ANT vs Apache MavenMudit Gupta
 
BlaBlaCar et la mise en place d'une fonctionnalité FlagFeature
BlaBlaCar et la mise en place d'une fonctionnalité FlagFeatureBlaBlaCar et la mise en place d'une fonctionnalité FlagFeature
BlaBlaCar et la mise en place d'une fonctionnalité FlagFeatureCocoaHeads France
 
Play! Framework for JavaEE Developers
Play! Framework for JavaEE DevelopersPlay! Framework for JavaEE Developers
Play! Framework for JavaEE DevelopersTeng Shiu Huang
 
#2 integration + ui tests
#2 integration + ui tests#2 integration + ui tests
#2 integration + ui testseleksdev
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)Chris Cowan
 
Titanium - Making the most of your single thread
Titanium - Making the most of your single threadTitanium - Making the most of your single thread
Titanium - Making the most of your single threadRonald Treur
 
Best Practices in apps development with Titanium Appcelerator
Best Practices in apps development with Titanium Appcelerator Best Practices in apps development with Titanium Appcelerator
Best Practices in apps development with Titanium Appcelerator Alessio Ricco
 
Deploying JHipster Microservices
Deploying JHipster MicroservicesDeploying JHipster Microservices
Deploying JHipster MicroservicesJoe Kutner
 
Play Framework: The Basics
Play Framework: The BasicsPlay Framework: The Basics
Play Framework: The BasicsPhilip Langer
 
OSX Complex Application Challenge Architecture
OSX Complex Application Challenge ArchitectureOSX Complex Application Challenge Architecture
OSX Complex Application Challenge ArchitectureCocoaHeads France
 
Using Play Framework 2 in production
Using Play Framework 2 in productionUsing Play Framework 2 in production
Using Play Framework 2 in productionChristian Papauschek
 
Telosys tutorial - Code generation for a Python web application based on Bott...
Telosys tutorial - Code generation for a Python web application based on Bott...Telosys tutorial - Code generation for a Python web application based on Bott...
Telosys tutorial - Code generation for a Python web application based on Bott...Laurent Guérin
 
F5 Automation and service discovery
F5 Automation and service discoveryF5 Automation and service discovery
F5 Automation and service discoveryScott van Kalken
 

Tendances (20)

Deploy your app with one Slack command
Deploy your app with one Slack commandDeploy your app with one Slack command
Deploy your app with one Slack command
 
Build a lego app with CocoaPods
Build a lego app with CocoaPodsBuild a lego app with CocoaPods
Build a lego app with CocoaPods
 
Node.js debugging
Node.js debuggingNode.js debugging
Node.js debugging
 
"I have a framework idea" - Repeat less, share more.
"I have a framework idea" - Repeat less, share more."I have a framework idea" - Repeat less, share more.
"I have a framework idea" - Repeat less, share more.
 
Apache ANT vs Apache Maven
Apache ANT vs Apache MavenApache ANT vs Apache Maven
Apache ANT vs Apache Maven
 
Cocoa pods
Cocoa podsCocoa pods
Cocoa pods
 
BlaBlaCar et la mise en place d'une fonctionnalité FlagFeature
BlaBlaCar et la mise en place d'une fonctionnalité FlagFeatureBlaBlaCar et la mise en place d'une fonctionnalité FlagFeature
BlaBlaCar et la mise en place d'une fonctionnalité FlagFeature
 
Play! Framework for JavaEE Developers
Play! Framework for JavaEE DevelopersPlay! Framework for JavaEE Developers
Play! Framework for JavaEE Developers
 
#2 integration + ui tests
#2 integration + ui tests#2 integration + ui tests
#2 integration + ui tests
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)
 
Titanium - Making the most of your single thread
Titanium - Making the most of your single threadTitanium - Making the most of your single thread
Titanium - Making the most of your single thread
 
Best Practices in apps development with Titanium Appcelerator
Best Practices in apps development with Titanium Appcelerator Best Practices in apps development with Titanium Appcelerator
Best Practices in apps development with Titanium Appcelerator
 
Deploying JHipster Microservices
Deploying JHipster MicroservicesDeploying JHipster Microservices
Deploying JHipster Microservices
 
Play Framework: The Basics
Play Framework: The BasicsPlay Framework: The Basics
Play Framework: The Basics
 
React Ecosystem
React EcosystemReact Ecosystem
React Ecosystem
 
OSX Complex Application Challenge Architecture
OSX Complex Application Challenge ArchitectureOSX Complex Application Challenge Architecture
OSX Complex Application Challenge Architecture
 
Using Play Framework 2 in production
Using Play Framework 2 in productionUsing Play Framework 2 in production
Using Play Framework 2 in production
 
Play framework
Play frameworkPlay framework
Play framework
 
Telosys tutorial - Code generation for a Python web application based on Bott...
Telosys tutorial - Code generation for a Python web application based on Bott...Telosys tutorial - Code generation for a Python web application based on Bott...
Telosys tutorial - Code generation for a Python web application based on Bott...
 
F5 Automation and service discovery
F5 Automation and service discoveryF5 Automation and service discovery
F5 Automation and service discovery
 

En vedette

CocoaHeads Rennes #14: iOS7 Controllers Transitions
 CocoaHeads Rennes #14: iOS7 Controllers Transitions CocoaHeads Rennes #14: iOS7 Controllers Transitions
CocoaHeads Rennes #14: iOS7 Controllers TransitionsCocoaHeadsRNS
 
Responsive design bookmarklet
Responsive design bookmarkletResponsive design bookmarklet
Responsive design bookmarkletCocoaHeads France
 
CocoaHeads Rennes #13 : Magical Record
CocoaHeads Rennes #13 : Magical RecordCocoaHeads Rennes #13 : Magical Record
CocoaHeads Rennes #13 : Magical RecordCocoaHeadsRNS
 
Design: a necessary evil by Roderic Andrews
Design: a necessary evil by Roderic AndrewsDesign: a necessary evil by Roderic Andrews
Design: a necessary evil by Roderic AndrewsCocoaHeads France
 
CocoaHeads Rennes #14: Programmation Responsive par Celedev
CocoaHeads Rennes #14: Programmation Responsive par CeledevCocoaHeads Rennes #14: Programmation Responsive par Celedev
CocoaHeads Rennes #14: Programmation Responsive par CeledevCocoaHeadsRNS
 
Présentation Raspberry Pi (cocoaheads remix)
Présentation Raspberry Pi (cocoaheads remix)Présentation Raspberry Pi (cocoaheads remix)
Présentation Raspberry Pi (cocoaheads remix)Arnaud Boudou
 
CocoaHeads Toulouse - Xcode et les tests - Epitez
CocoaHeads Toulouse - Xcode et les tests - EpitezCocoaHeads Toulouse - Xcode et les tests - Epitez
CocoaHeads Toulouse - Xcode et les tests - EpitezCocoaHeads France
 

En vedette (15)

Test flight
Test flightTest flight
Test flight
 
CocoaHeads Rennes #14: iOS7 Controllers Transitions
 CocoaHeads Rennes #14: iOS7 Controllers Transitions CocoaHeads Rennes #14: iOS7 Controllers Transitions
CocoaHeads Rennes #14: iOS7 Controllers Transitions
 
Place it
Place itPlace it
Place it
 
iTunes Stats
iTunes StatsiTunes Stats
iTunes Stats
 
Responsive design bookmarklet
Responsive design bookmarkletResponsive design bookmarklet
Responsive design bookmarklet
 
Drag & drop
Drag & dropDrag & drop
Drag & drop
 
Fail better
Fail betterFail better
Fail better
 
CocoaHeads Rennes #13 : Magical Record
CocoaHeads Rennes #13 : Magical RecordCocoaHeads Rennes #13 : Magical Record
CocoaHeads Rennes #13 : Magical Record
 
Nm paginator
Nm paginatorNm paginator
Nm paginator
 
Icon preview tool
Icon preview toolIcon preview tool
Icon preview tool
 
Design: a necessary evil by Roderic Andrews
Design: a necessary evil by Roderic AndrewsDesign: a necessary evil by Roderic Andrews
Design: a necessary evil by Roderic Andrews
 
Ns operationqueue
Ns operationqueueNs operationqueue
Ns operationqueue
 
CocoaHeads Rennes #14: Programmation Responsive par Celedev
CocoaHeads Rennes #14: Programmation Responsive par CeledevCocoaHeads Rennes #14: Programmation Responsive par Celedev
CocoaHeads Rennes #14: Programmation Responsive par Celedev
 
Présentation Raspberry Pi (cocoaheads remix)
Présentation Raspberry Pi (cocoaheads remix)Présentation Raspberry Pi (cocoaheads remix)
Présentation Raspberry Pi (cocoaheads remix)
 
CocoaHeads Toulouse - Xcode et les tests - Epitez
CocoaHeads Toulouse - Xcode et les tests - EpitezCocoaHeads Toulouse - Xcode et les tests - Epitez
CocoaHeads Toulouse - Xcode et les tests - Epitez
 

Similaire à Accessors Vs Direct access to properties & Design Pattern

Java programming concept
Java programming conceptJava programming concept
Java programming conceptSanjay Gunjal
 
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023Nicolas HAAN
 
Application Security from the Inside - OWASP
Application Security from the Inside - OWASPApplication Security from the Inside - OWASP
Application Security from the Inside - OWASPSqreen
 
Mobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve MobileMobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve MobileKonstantin Loginov
 
Context and Dependency Injection
Context and Dependency InjectionContext and Dependency Injection
Context and Dependency InjectionWerner Keil
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0Michael Vorburger
 
Method, Constructor, Method Overloading, Method Overriding, Inheritance In Java
Method, Constructor, Method Overloading, Method Overriding, Inheritance In  JavaMethod, Constructor, Method Overloading, Method Overriding, Inheritance In  Java
Method, Constructor, Method Overloading, Method Overriding, Inheritance In JavaJamsher bhanbhro
 
iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)Netcetera
 
Getting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with ThymeleafGetting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with ThymeleafMasatoshi Tada
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEBenjamin Cabé
 
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6Saltmarch Media
 
Lunch and learn as3_frameworks
Lunch and learn as3_frameworksLunch and learn as3_frameworks
Lunch and learn as3_frameworksYuri Visser
 
Pentesting iOS Apps - Runtime Analysis and Manipulation
Pentesting iOS Apps - Runtime Analysis and ManipulationPentesting iOS Apps - Runtime Analysis and Manipulation
Pentesting iOS Apps - Runtime Analysis and ManipulationAndreas Kurtz
 
Native Cloud-Native: Building Agile Microservices with the Micronaut Framework
Native Cloud-Native: Building Agile Microservices with the Micronaut FrameworkNative Cloud-Native: Building Agile Microservices with the Micronaut Framework
Native Cloud-Native: Building Agile Microservices with the Micronaut FrameworkZachary Klein
 
Cocoa Heads Tricity - Design Patterns
Cocoa Heads Tricity - Design PatternsCocoa Heads Tricity - Design Patterns
Cocoa Heads Tricity - Design PatternsMaciej Burda
 
Intro to iOS Development • Made by Many
Intro to iOS Development • Made by ManyIntro to iOS Development • Made by Many
Intro to iOS Development • Made by Manykenatmxm
 
[COSCUP 2023] 我的Julia軟體架構演進之旅
[COSCUP 2023] 我的Julia軟體架構演進之旅[COSCUP 2023] 我的Julia軟體架構演進之旅
[COSCUP 2023] 我的Julia軟體架構演進之旅岳華 杜
 
Test-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptxTest-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptxVictor Rentea
 

Similaire à Accessors Vs Direct access to properties & Design Pattern (20)

Java programming concept
Java programming conceptJava programming concept
Java programming concept
 
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
 
Application Security from the Inside - OWASP
Application Security from the Inside - OWASPApplication Security from the Inside - OWASP
Application Security from the Inside - OWASP
 
Mobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve MobileMobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve Mobile
 
Context and Dependency Injection
Context and Dependency InjectionContext and Dependency Injection
Context and Dependency Injection
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0
 
Method, Constructor, Method Overloading, Method Overriding, Inheritance In Java
Method, Constructor, Method Overloading, Method Overriding, Inheritance In  JavaMethod, Constructor, Method Overloading, Method Overriding, Inheritance In  Java
Method, Constructor, Method Overloading, Method Overriding, Inheritance In Java
 
iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)
 
Getting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with ThymeleafGetting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with Thymeleaf
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDE
 
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
 
Lunch and learn as3_frameworks
Lunch and learn as3_frameworksLunch and learn as3_frameworks
Lunch and learn as3_frameworks
 
Pentesting iOS Apps - Runtime Analysis and Manipulation
Pentesting iOS Apps - Runtime Analysis and ManipulationPentesting iOS Apps - Runtime Analysis and Manipulation
Pentesting iOS Apps - Runtime Analysis and Manipulation
 
Native Cloud-Native: Building Agile Microservices with the Micronaut Framework
Native Cloud-Native: Building Agile Microservices with the Micronaut FrameworkNative Cloud-Native: Building Agile Microservices with the Micronaut Framework
Native Cloud-Native: Building Agile Microservices with the Micronaut Framework
 
Cocoa Heads Tricity - Design Patterns
Cocoa Heads Tricity - Design PatternsCocoa Heads Tricity - Design Patterns
Cocoa Heads Tricity - Design Patterns
 
Intro to iOS Development • Made by Many
Intro to iOS Development • Made by ManyIntro to iOS Development • Made by Many
Intro to iOS Development • Made by Many
 
[COSCUP 2023] 我的Julia軟體架構演進之旅
[COSCUP 2023] 我的Julia軟體架構演進之旅[COSCUP 2023] 我的Julia軟體架構演進之旅
[COSCUP 2023] 我的Julia軟體架構演進之旅
 
Test-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptxTest-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptx
 
Data herding
Data herdingData herding
Data herding
 
Data herding
Data herdingData herding
Data herding
 

Plus de CocoaHeads France

Plus de CocoaHeads France (20)

Mutation testing for a safer Future
Mutation testing for a safer FutureMutation testing for a safer Future
Mutation testing for a safer Future
 
iOS App Group for Debugging
iOS App Group for DebuggingiOS App Group for Debugging
iOS App Group for Debugging
 
Asynchronous swift
Asynchronous swiftAsynchronous swift
Asynchronous swift
 
Visual accessibility in iOS11
Visual accessibility in iOS11Visual accessibility in iOS11
Visual accessibility in iOS11
 
My script - One year of CocoaHeads
My script - One year of CocoaHeadsMy script - One year of CocoaHeads
My script - One year of CocoaHeads
 
Ui testing dealing with push notifications
Ui testing dealing with push notificationsUi testing dealing with push notifications
Ui testing dealing with push notifications
 
CONTINUOUS DELIVERY WITH FASTLANE
CONTINUOUS DELIVERY WITH FASTLANECONTINUOUS DELIVERY WITH FASTLANE
CONTINUOUS DELIVERY WITH FASTLANE
 
L'intégration continue avec Bitrise
L'intégration continue avec BitriseL'intégration continue avec Bitrise
L'intégration continue avec Bitrise
 
Super combinators
Super combinatorsSuper combinators
Super combinators
 
Design like a developer
Design like a developerDesign like a developer
Design like a developer
 
Handle the error
Handle the errorHandle the error
Handle the error
 
Quoi de neuf dans iOS 10.3
Quoi de neuf dans iOS 10.3Quoi de neuf dans iOS 10.3
Quoi de neuf dans iOS 10.3
 
IoT Best practices
 IoT Best practices IoT Best practices
IoT Best practices
 
SwiftyGPIO
SwiftyGPIOSwiftyGPIO
SwiftyGPIO
 
Présentation de HomeKit
Présentation de HomeKitPrésentation de HomeKit
Présentation de HomeKit
 
Programme MFI retour d'expérience
Programme MFI retour d'expérienceProgramme MFI retour d'expérience
Programme MFI retour d'expérience
 
How to communicate with Smart things?
How to communicate with Smart things?How to communicate with Smart things?
How to communicate with Smart things?
 
Let's migrate to Swift 3.0
Let's migrate to Swift 3.0Let's migrate to Swift 3.0
Let's migrate to Swift 3.0
 
Project Entourage
Project EntourageProject Entourage
Project Entourage
 
What's new in iOS9
What's new in iOS9What's new in iOS9
What's new in iOS9
 

Dernier

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Dernier (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

Accessors Vs Direct access to properties & Design Pattern

  • 3. Au programme • Accessors Vs Direct access to properties • Design Pattern : Categories • Design Pattern : Associative Storage • La chaine Météo! mardi 28 mai 13
  • 4. iVar : Accessors/Direct access • Performance ? • Risks / Limits ? mardi 28 mai 13
  • 5. property Using setter (ms) Using Direct Access (ms) strong + nonatomic 9 6 weak + nonatomic 30 30 unsafe_unretained + nonatomic 0,8 0,2 strong + atomic 9 6 iPhone 3GS/iOS5 + 10,000 affectactions. (average based on several tests.) iVar : Accessors/Direct access Performance? mardi 28 mai 13
  • 6. • Direct affectation don’t use the property attributes (atomic) • KVO/KVC needs accessors, • Don’t use accessor methods in init methods and dealloc (You may have override your accessors) iVar : Accessors/Direct access Risk / Limits? mardi 28 mai 13
  • 7. Design Pattern: Categories • Add new methods to existing classes #import "IBSHelper.h" @interface IBSHelper (FileName) + (NSString*)filenameForGeolocData; + (NSString*)filenameForBrandCodeData; + (NSString*)filenameForTradData; + (NSString *)currentLanguage; + (NSString *)currentLanguageForDownload; + (NSURL*)urlForGeolocData; + (NSURL*)urlForBrandData; + (NSURL*)urlForTradData; @end mardi 28 mai 13
  • 8. Design Pattern: Categories • Organize/split complexity mardi 28 mai 13
  • 9. Design Pattern: Categories • Makes easy to support multiple OS versions @interface UITableView (BkUICore) - (void) bkRegisterNibName:(NSString *)nibName forCellReuseIdentifier: (NSString *)identifier; - (id) bkDequeueReusableCellWithIdentifier:(NSString *)identifier; @end @interface UIViewController (BkUICore) - (void) bkDismissModalViewControllerAnimated:(BOOL)animated; - (void) bkPresentViewController:(UIViewController *)controller animated:(BOOL)animated; @end mardi 28 mai 13
  • 10. Design Pattern: Categories • Categories can be used to declare either instance methods or class methods but are not usually suitable for declaring additional properties. One other design pattern can help us ! Associated storage @interface UITableView (BkUICore) - (void) bkRegisterNibName:(NSString *)nibName forCellReuseIdentifier: (NSString *)identifier; - (id) bkDequeueReusableCellWithIdentifier:(NSString *)identifier; @end mardi 28 mai 13
  • 11. Design Pattern: Associative references http://developer.apple.com/library/mac/#documentation/ Cocoa/Conceptual/ObjCRuntimeGuide/Introduction/ Introduction.html#//apple_ref/doc/uid/TP40008048 Objective-C programs interact with the runtime system at three distinct levels: through Objective-C source code; through methods defined in the NSObject class of the Foundation framework; and through direct calls to runtime functions. mardi 28 mai 13
  • 12. Design Pattern: Associative references //nsobjet.h @interface NSObject + (Class)superclass; + (Class)class; - (BOOL)respondsToSelector:(SEL)aSelector; + (BOOL)conformsToProtocol:(Protocol *)protocol; //runtime.h OBJC_EXPORT Class class_getSuperclass(Class cls) OBJC_EXPORT Class object_getClass(id obj) OBJC_EXPORT BOOL class_respondsToSelector(Class cls, SEL sel) OBJC_EXPORT BOOL class_conformsToProtocol(Class cls, Protocol *protocol) Some of the NSObject methods simply query the runtime system for information. These methods allow objects to perform introspection. mardi 28 mai 13
  • 13. • A way to add simulate new properties to an existing class ! Design Pattern: Associative references static const char nibsAssocKey; @implementation UITableView (BkUICore) - (void) bkRegisterNibName:(NSString *)nibName forCellReuseIdentifier:(NSString *)identifier { if ([self respondsToSelector:@selector(registerNib:forCellReuseIdentifier:)]) { [self registerNib:[UINib nibWithNibName:nibName bundle:[NSBundle mainBundle]] forCellReuseIdentifier:identifier]; //NS_AVAILABLE_IOS(5_0) } else { NSMutableDictionary *nibs = objc_getAssociatedObject(self, &nibsAssocKey); if (nil == nibs) { nibs = [NSMutableDictionary dictionary]; objc_setAssociatedObject(self, &nibsAssocKey, nibs, OBJC_ASSOCIATION_RETAIN); } [nibs setValue:nibName forKey:identifier]; } } @end mardi 28 mai 13
  • 14. La chaine meteo Issue : How to add a new property on UINavigationBar • Subclass UINavigationBar, dumbass ! • Use associated storage ! mardi 28 mai 13
  • 16. Other examples • UIView + BkBadge • UIView + BkLoader .... mardi 28 mai 13