iphone - ARC 是否意味着我应该声明静态类型而不是 id?

标签 iphone objective-c ios automatic-ref-counting

ARC 文档可在 LLVM 网站上公开获取,因此 NDA 在这里不是问题。

我发现,在为 ARC 准备代码时,我在很多以前使用 (id) 的情况下使用 (NSObject*)。

例如,如果我正在编写一个 initWithParent: 方法,它可能是

-(id) initWithParent: (NSObject*) parent;

我以前会写的地方

-(id) initWithParent: (id) parent;

我的问题是——这种做法有意义吗?

最佳答案

我相信这适用于大多数情况,至少如果您的对象派生自 NSObject(并非所有情况都如此)。 Here's an interesting blog post on the subject (独立于 ARC)。

关于iphone - ARC 是否意味着我应该声明静态类型而不是 id?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6585278/

相关文章:

iphone - iPhone代码的图像识别库/API

iphone - HTTP连接的 'didReceiveData'方法的讨论

objective-c - 开始工作表 : block alternative with ARC?

ios - 键盘在 UIViewController Xamarin IOS 中隐藏 UITextView

ios - 在 iOS 中比较两个音频文件

iphone - iOS更新之间的常数会保持不变吗?

iphone - Restkit Objective-C : Post request only works once

iphone - 我应该使用 if 还是 switch 语句? Objective-C

objective-c - 检测 cocoa 中的键盘事件,特别是 Return/Tab 键

iphone - 如何第二次请求用户允许访问当前位置?