iOS.ObjC.Basic-Knowledge

1. ObjC的基础 

2. ObjC2.0中的编译指令

3. ObjC Runtime

4. ObjC Object Model

5. ObjC的新语法

6. FQA

 

1. ObjC的基础

2. ObjC2.0中的编译指令

http://www.learn-cocos2d.com/2011/10/complete-list-objectivec-20-compiler-directives/

http://developer.apple.com/library/mac/#releasenotes/Cocoa/RN-ObjectiveC/index.html

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中是什么作用?

转载于:https://www.cnblogs.com/cwgk/p/3196560.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值