ios读书笔记

1.LLVM4自动合成的实例变量以下划线_开头。

2.The runtime method, setValue:forKey:used by KVC, writes to an ivar specified by key prefixed with a leading underscore if an ivar specified in the forKey argument is not declared. As such,[myObject setValue:@1 forKey:@”number”]; will set the value of 1 to the ivar _number if an ivar named number (without the leading underscore) is not declared. The auto-synthesized ivars in LLVM 4.0 might be troublesome in some cases like lazy read/write ivars. In those cases, synthesize your ivars explicitly by prefixing them with a double underscore. This edge case applies to read-only properties as well. To prevent your read-only properties from being written to using runtime KVC methods, prefix their synthesizers with a double underscore. Apple uses the double underscore prefix for lazily loaded properties (NSManagedObjectContext and NSPersistentStoreCoordinator) in your application delegate if you use Core Data.



你可能感兴趣的:(ios读书笔记)