我已经在不同的来源阅读过这样的问题:书籍、文章等,但无法理解它。当出现支持 i-var 和属性的问题以及如何解决它时,您能举个例子吗?我已经从这里http://blog.bignerdranch.com/463-a-motivation-for-ivar-decorations阅读了以下代码。
@property (copy) NSString *name;
...
@synthesize name;
...
- (void) setPonyInfoFromPropertyDict: (NSDictionary *) ponyProperties {
NSString *name = [ponyProperties objectForKey: @"Name"];
ponyName = name; //self.ponyName=name should solve the problem?
}
NSMutableString *mutableName = [NSMutableString stringWithString: @"Mikey"];
NSDictionary *ponyProperties = [NSDictionary dictionaryWithObject: mutableName
forKey: @"Name"];
[pony setPonyInfoFromPropertyDict: ponyProperties];
[mutableName setString: @"Wookiee"];
该代码和文章是否与此问题有关?而正确的方法是使用 self.ponyName=name? 在任何其他设置方法中?