摘要: 四.使用关联引用为分类添加数据 虽然不能在分类中创建实例变量,但是可以创建关联引用(associative reference)。通过关联引用,你可以向任何对象中添加键-值(key-value)数据。 假如有一个Person类,这个person类可能会被用在其他程序中,有些电子邮件地址(emailAddress)这个字段是有意义的,有些时候这个字段是没有用的。一个比较好的解决方案就是使用分类为Person类添加一个名为emailAddress的属性,这样可以避免不需要emailAddress时的开销。或许Person类并不是你写的,改类的维护者也不会为你添加这个属性。这种情况下,要怎么解决.. 阅读全文
posted @ 2013-06-24 17:38 gagag 阅读(347) 评论(0) 推荐(0) 编辑
摘要: 原文:http://www.noxeos.com/2011/07/29/c-const-static-keywords/C: const and static keywordsOk, once and for all, I’ll try to clarify to meaning of the ‘const’ and ‘static’ keywords in C (it applies to Objective-C and C++ too).I’m just tired of questions about this on StackOverflow.Objective-C programme 阅读全文
posted @ 2013-06-24 15:09 gagag 阅读(419) 评论(0) 推荐(0) 编辑