Archive for May, 2011
Meanings of Base SDK and Deployment Target
Please read SDK Compatibility Guide to get details.
(http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/cross_development)
Weak Linking
- No link errors occur even if you don't have symbols(variables, methods, classes) to be linked.
- No runtime errors occur even if you don't have symbols to be loaded.
- Therefore, you must ensure the availability of the symbols before using them.
Strong Linking
- Link errors or runtime errors occur if you don't have symbols.
Base SDK Version
- The maximum version of SDK(or iOS) on which your app can run.
- You can not use the new features introduced in the higher versions.
Deployment Target Version
- The minimum version of SDK(of iOS) on which your app can run.
- The symbols in the versions higher than this are weakly linked.
- The symbols in the versions lower or equal to this are strongly linked.
How to use
- Determine the minimum and the maximum version on which your app can run.
- Set the maximum version to the Base SDK version.
- Set the minimum version to the Deployment Target.
- For weakly linked symbols, you must ensure the availability of them at runtime before using them.
- For strongly linked symbols, it will make errors at compile time.
Special Note
- If the superclass is unavailable, the subclass is unavailable, too.
- If the delegate which your class implements is unavailable, a runtime error occurs when your app is loaded.
Tip
- To make compile errors for expected problems on a specific version of iOS, set the iOS version to the Base SDK version and build your project.
Using private properties in Objective-C 2.0
You can use class extension to hide properties from the header.
// A.h
@interface A : NSObject {
}
-(void)setXXX:(int)i;
-(int)xxx;
@end
// A.m
#import "A.h"
@interface A()
@property int m; // HERE
@end
@implementation A
@synthesize m; // AND HERE
-(void)setXXX:(int)i {
self.m = i;
}
-(int)xxx {
return self.m;
}
@end
Class extension is better than category because
- You can define properties.
- Declaring a method without an implementation makes an error.