有人可以解释这个@synthesize语法吗? [英] Can someone explain this @synthesize syntax?

查看:111
本文介绍了有人可以解释这个@synthesize语法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注最新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语法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆