Professional Documents
Culture Documents
Stefan Tsvyatkov
iOS Department Manager,
Galin Kardzhilov
Senior iOS Developer,
Andrey Marinov
Senior iOS Developer,
Q&A
Clean, Secure and Fast iOS
Stefan Tsvyatkov
iOS Department Manager,
Galin Kardzhilov
Senior iOS Developer,
Andrey Marinov
Senior iOS Developer,
Q&A
Security in iOS
Local Storage
Q&A
Security in iOS
Local Storage
re
Convenient
u
Not encrypted by default
ec
Keeps the data in a plist file
t s
No
CoreData
Encrypted by default
Custom
algorithm
Data encryption
Crypto API
Local Storage
re
Convenient
cu
Not encrypted by default
s e
ot
CoreData
N
Not encrypted by default
Encrypted by default
Custom
algorithm
Data encryption
Crypto API
Use SSL
Runtime Manipulation
ptrace
Encrypted by default
Custom
algorithm
Data encryption
Crypto API
Use SSL
Runtime Manipulation
ptrace
Runtime Manipulation
!
SEC_IS_BEING_DEBUGGED_RETURN_NIL()
#ifndef
! DEBUG
SEC_IS_BEING_DEBUGGED_RETURN_NIL();
#endif
!
Runtime Manipulation
ptrace
Runtime Manipulation
!
SEC_IS_BEING_DEBUGGED_RETURN_NIL()
#ifndef
! DEBUG
SEC_IS_BEING_DEBUGGED_RETURN_NIL();
#endif
!
Conclusion
Runtime Manipulation
!
SEC_IS_BEING_DEBUGGED_RETURN_NIL()
#ifndef
! DEBUG
SEC_IS_BEING_DEBUGGED_RETURN_NIL();
#endif
!
Conclusion
return result;
}
Class Naming
Class names are always capitalized Standard Classes
NSString
Objective-C doesnt have namespaces
NSMutableDictionary
Custom Classes
NS stands for NeXTSTEP
MCUser
MCEmailAttachment
MCServiceClient
Custom Subclasses
MCTableView
MCCollectionView
SSL for transporting
return result;
}
Class Naming
Class names are always capitalized Standard Classes
NSString
Objective-C doesnt have namespaces
NSMutableDictionary
Custom Classes
NS stands for NeXTSTEP
MCUser
MCEmailAttachment
MCServiceClient
Custom Subclasses
MCTableView
MCCollectionView
MCView
Variable names
camelCase
NSString *streetAddress = @"1 Infinite Loop";
NSString *cityName = @"Cupertino";
NSString *countyName = @"Santa Clara";
Class Naming
Class names are always capitalized Standard Classes
NSString
Objective-C doesnt have namespaces
NSMutableDictionary
Custom Classes
NS stands for NeXTSTEP
MCUser
MCEmailAttachment
MCServiceClient
Custom Subclasses
MCTableView
MCCollectionView
MCView
Variable names
camelCase
NSString *streetAddress = @"1 Infinite Loop";
NSString *cityName = @"Cupertino";
NSString *countyName = @"Santa Clara";
Method Names
// Example from another language
object.begin(resource);
object.processData(resource, data, true);
object.end(true);
Cocoa/Objective-C
[fileWrapper writeToFile:path atomically:YES updateFilenames:YES];
Method Names
// Example from another language
object.begin(resource);
object.processData(resource, data, true);
object.end(true);
Cocoa/Objective-C
[fileWrapper writeToFile:path atomically:YES updateFilenames:YES];
Adjectives
Property selectable, getter -isSelectable, setter -setSelectable:
Method Names
// Example from another language
object.begin(resource);
object.processData(resource, data, true);
object.end(true);
Cocoa/Objective-C
[fileWrapper writeToFile:path atomically:YES updateFilenames:YES];
Adjectives
Property selectable, getter -isSelectable, setter -setSelectable:
// Example
realPath = [path stringByExpandingTildeInPath];
fullString = [string stringByAppendingString:@Having a great time?];
object = [array objectAtIndex:3];
// class methods
newString = [NSString stringWithFormat:@"%f",1.5];
newArray = [NSArray arrayWithObject:newString];
// copy objects from the NSArray to the buffer
id *buffer = (id *) malloc(sizeof(id) * [array count]);
[array getObjects: buffer];
Adjectives
Property selectable, getter -isSelectable, setter -setSelectable:
// Example
realPath = [path stringByExpandingTildeInPath];
fullString = [string stringByAppendingString:@Having a great time?];
object = [array objectAtIndex:3];
// class methods
newString = [NSString stringWithFormat:@"%f",1.5];
newArray = [NSArray arrayWithObject:newString];
// Example
capitalized = [name capitalizedString];
rate = [number floatValue];
newString = [string decomposedStringWithCanonicalMapping];
subarray = [array subarrayWithRange:segment];
Avoid Ambiguity
// Ambiguous Messages
-sortInfo // returns sort info, or sort something called "info"?
-refreshTimer // return a timer used for refreshing, or refresh a timer?
-update // a verb? what is updated and how?
-fetchInfo: // fetch info about something or give info about a fetch?
Methods Names: Returning Objects
Based on conditions or input
[object/class thing+condition];
[object/class thing+input:input];
[object/class thing+identifer:input];
// Example
realPath = [path stringByExpandingTildeInPath];
fullString = [string stringByAppendingString:@Having a great time?];
object = [array objectAtIndex:3];
// class methods
newString = [NSString stringWithFormat:@"%f",1.5];
newArray = [NSArray arrayWithObject:newString];
// Example
capitalized = [name capitalizedString];
rate = [number floatValue];
newString = [string decomposedStringWithCanonicalMapping];
subarray = [array subarrayWithRange:segment];
Avoid Ambiguity
// Ambiguous Messages
-sortInfo // returns sort info, or sort something called "info"?
-refreshTimer // return a timer used for refreshing, or refresh a timer?
-update // a verb? what is updated and how?
-fetchInfo: // fetch info about something or give info about a fetch?
// Clear Messages
-currentSortInfo // "current" obviously describes the noun "sort info"
-refreshDefaultTimer // refresh is now clearly a verb
-updateMenuItemTitle // an action is taking place
-infoForFetch: // now we know info is returned for a fetch
Global C Functions
NSHomeDirectory()
Prefix + Value ()
NSHomeDirectoryForUser()
Prefix + Value + With/From/For + Input ()
NSClassFromString()
Prefix + Action ()
NSBeginAlertSheet()
Prefix + Action + Type ()
NSDrawGrayBezel()
Avoid Ambiguity
// Ambiguous Messages
-sortInfo // returns sort info, or sort something called "info"?
-refreshTimer // return a timer used for refreshing, or refresh a timer?
-update // a verb? what is updated and how?
-fetchInfo: // fetch info about something or give info about a fetch?
// Clear Messages
-currentSortInfo // "current" obviously describes the noun "sort info"
-refreshDefaultTimer // refresh is now clearly a verb
-updateMenuItemTitle // an action is taking place
-infoForFetch: // now we know info is returned for a fetch
Global C Functions
NSHomeDirectory()
Prefix + Value ()
NSHomeDirectoryForUser()
Prefix + Value + With/From/For + Input ()
NSClassFromString()
Prefix + Action ()
NSBeginAlertSheet()
Prefix + Action + Type ()
NSDrawGrayBezel()
Abbreviations
Abbreviations
Abbreviations
Abbreviations
Summary
Be consistent
Be descriptive
NSMallocException
NSInvalidArgumentException
Abbreviations
Abbreviations
Summary
Be consistent
Be descriptive
Moving on
LP64
Clean, Secure and Fast iOS
A new frontier
Summary
Be consistent
Be descriptive
Moving on
LP64
Clean, Secure and Fast iOS
A new frontier
Same as OS X
A new frontier
Same as OS X
Runtime optimizations
Optimizations
Runtime optimizations
Optimizations
Tagged pointers
Optimizations
Tagged pointers
Use NSInteger/CGFloat
NSInteger ook = 4242424242424242;
NSLog (@"%ld",
(@"%@",
(@"%d", @(ook));
ook);
(long)ook);
Conclusion
Tagged pointers
Use NSInteger/CGFloat
NSInteger ook = 4242424242424242;
NSLog (@"%ld",
(@"%@",
(@"%d", @(ook));
ook);
(long)ook);
Conclusion
Untapped potential
Questions?
Conclusion
Untapped potential
Questions?
Contact Us
#mobconbg
Contact Us
#mobconbg