有人可以解释这个@synthesize语法吗?

编程入门 行业动态 更新时间:2024-10-27 14:33:40
本文介绍了有人可以解释这个@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语法吗?

本文发布于:2023-06-13 09:41:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/679110.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语法   synthesize

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!