1. ObjC的基础
2. ObjC2.0中的编译指令
3. ObjC Runtime
4. ObjC Object Model
5. ObjC的新语法
6. FQA
1. ObjC的基础
2. ObjC2.0中的编译指令
3. ObjC Runtime
3.1 class method 中的self 和 instance method中的self不同点在哪?
Within the body of a class method, self
refers to the class object itself.
参见: https://developer.apple.com/library/ios/documentation/general/conceptual/DevPedia-CocoaCore/ClassMethod.html
3.2 metaclass
http://www.cocoawithlove.com/2010/01/what-is-meta-class-in-objective-c.html
Class and metaclass:
http://www.sealiesoftware.com/blog/archive/2009/04/14/objc_explain_Classes_and_metaclasses.html
http://resources.infosecinstitute.com/ios-application-security-part-3-understanding-the-objective-c-runtime/
4. ObjC的新语法
4.1 属性只需要声明(使用property指令), 而不需要@synthesize指令,那么会发生什么?
@interface Context : NSObject
@property (nonatomic, strong) NSMutableString *text;
4.2 @import
例如:
@import UIKit
4.X Modern Objective-C: WWDC 2012 Session 405 (TODO)
5. QA
5.1 NSCopying NSMutableCopying
Implement "- (id)copyWithZone:(NSZone *)zone" for immutalbe object.
ARC:
- (id) copyWithZone:(NSZone *)zone { return self; }
MRC:
-(id) copyWithZone:(NSZone*)zone { return[self retain]; }
- (id)mutableCopyWithZone:(NSZone *)zone
Ref:
A. POP, POPAnimatableProperty类
B. http://stackoverflow.com/questions/9127198/objective-c-immutable-object-copywithzone-arc-compatible-realization
5.2
NS_RETURNS_RETAINED
NS_RETURNS_NOT_RETAINED
CF_RETURNS_RETAINED
CF_RETURNS_NOT_RETAINED
NS_RELEASES_ARGUMENT
CF_RELEASES_ARGUMENT
Ref
A. http://clang-analyzer.llvm.org/annotations.html
B. http://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-object-operands-retained-return-values
5.3
NSObject的接口
"+ (id)allocWithZone:(struct _NSZone *)zone" 在子类该如何实现呢,该接口在ObjC中是什么作用?