我正在关注最新iOS SDK中带有核心数据的示例导航视图模板。
I'm following the example Navigation View template with core data in the latest iOS SDK.
在 rootViewController.m file我在@synthesize行中看到了这个:
In the rootViewController.m file I see this in the @synthesize line:
@synthesize fetchedResultsController=fetchedResultsController_, managedObjectContext=managedObjectContext_;头文件的位置是:
@private NSFetchedResultsController *fetchedResultsController_; NSManagedObjectContext *managedObjectContext_;}
@property (nonatomic, retain) NSManagedObjectContext *managedObjectContext; @property (nonatomic, retain) NSFetchedResultsController *fetchedResultsController;这是否意味着它们都是@synthesized(创建getter& setter)但是之后设置了一个与另一个相等?看来 fetchedResultsController 也是 rootViewController.m 文件中的一个方法。
Does this mean that they are both @synthesized (creating getters & setters) but then one is set to equal the other? It also appears that fetchedResultsController is also a method in the rootViewController.m file.
这个模板在这个SDK版本中已经改变了,我正在关注Apress书籍更多的iPhone 3开发,这确实让人感到困惑。
This template has changed in this SDK version, i'm following the Apress book More iPhone 3 development and this has really confused matters.
推荐答案只有第一个(在Synthesis语句的lhs上)与getter和setter合成并成为public 实例变量。
Only the first one (on the lhs of the synthesize statement) is synthesized with a getter and setter and becomes the "public" instance variable.
后者(使用下划线)仍然可以在实例中使用,但不会在实例外部公开。它们都引用相同的内存地址。
The latter (with the underscore) is still available inside the instance but is not exposed outside the instance. They both reference the same memory address.
更多推荐
有人可以解释这个@synthesize语法吗?
发布评论