现在的位置: 首页 > 综合 > 正文

学习笔记 iOS development-Standford university-lesson3-Objective C

2013年05月21日 ⁄ 综合 ⁄ 共 451字 ⁄ 字号 评论关闭

1. Property中strong和weak的区别
property(strong) NSString *string1;
property(strong) NSString *string2; // 将strong替换成weak测试一下

string1 = @"111";
string2 = string1;
string1 = nil;
NSLog(@"string2 : %@", string2);

weak引用的释放在counter为0的时候立即发生,和ObjectiveC垃圾回收没有任何关系。
need more research:Objective C会在编译的时候自动加入counter的引用和释放代码?

Retain和release方法在iOS5中已经不再使用

可以用if(obj)判断一个对象是否为nil

在调用方法的时候,如果该对象为nil,不会抛出异常,如果该方法返回int型,则会返回0

两种方式可以调用类方法
[ClassName method] or [[instance class] method]

父类必须要指定一个初始化方法供子类使用

抱歉!评论已关闭.