摘要:
【深入剖析AutoreleasePool】 Objc的AutoreleasePool是一个首尾相连的内存链接,每块大小为1页(32位机上为4kb)。 上面可以看到,parent指向父Pool,child指向子Pool,因初始化时无child Pool,所以child被置为NULL。next指向当前内存块中的最大位置,即每个块内是一个4kb的栈。 通过以下方很容易看出AutoreleasePoolPage如果使用: 当一个AutorreleasePool被释放时,在该pool之后的pool所涵盖的对象均会被释放。 阅读全文
posted @ 2014-02-16 23:46
Tekkaman
阅读(447)
评论(0)
推荐(0)
摘要:
【Preprocess】 在使用forwarding机制前,会先经历2个步骤,只有当这2个步骤均失败的情况下,才会激活forwarding。1、+(BOOL)resolveInstanceMethod:(SEL)selector、resolveClassMethod。 当第一次没找到SEL时,调... 阅读全文
posted @ 2014-02-16 23:12
Tekkaman
阅读(611)
评论(0)
推荐(0)
摘要:
【Dynamic Method Resolution】 @dynamic directive 用于声明属性的方法dynamic loading,which tells the compiler that the methods associated with the property will be provided dynamically。即编译期不实现此方法,而由动态加载。此directive的作用在于告诉编译器某个类的实例拥有某属性而不会报编译错误。 You can implement the methods resolveInstanceMethod: and resolveCla.. 阅读全文
posted @ 2014-02-16 22:43
Tekkaman
阅读(326)
评论(0)
推荐(0)
摘要:
【Represent nil with NSNull】 It’s not possible to add nil to the collection classes described in this section because nil in Objective-C means “no object.” If you need to represent “no object” in a collection, you can use the NSNull class:1 NSArray *array = @[ @"string", @42, [NSNull null] 阅读全文
posted @ 2014-02-16 11:35
Tekkaman
阅读(405)
评论(0)
推荐(0)
摘要:
【Encapsulating Data】The synthesized methods follow specific naming conventions:The method used to access the value (thegettermethod) has the same name as the property. The getter method for a property calledfirstNamewill also be calledfirstName.The method used to set the value (thesettermethod) star 阅读全文
posted @ 2014-02-16 10:16
Tekkaman
阅读(292)
评论(0)
推荐(0)
浙公网安备 33010602011771号