2013-04-22 83 views
0

我正在尝试学习Objective-C。所以我刚刚实施了ProfileViewController这里是我的头文件:“强”属性问题

#import <UIKit/UIKit.h> 

@interface ProfileViewController : UIViewController 

@property (strong, nonatomic) UIScrollView *scrollView;//strong is not colored by XCode 

@end 

但我与@property线下面的错误,我完全坚持了下来:

No 'assign', 'retain' or 'copy' attribute is specified - 'assign' is assumed 
Default property 'assign' not appropriate for non-gc object 

而且在我ProfileViewController.m我有以下警告:Property 'scrollView' needs setScrollView need to be defined

Developer Information: 

    Version: 4.1 (4B110) 
    Location: /Developer 
    Applications: 
    Xcode: 4.1 (516) 
    Instruments: 4.1 (4138) 
    Dashcode: 3.0.2 (336) 
    SDKs: 
    Mac OS X: 
    10,6: (10J567) 
    10,7: (11A511a) 
    iPhone OS: 
    4,3: (8H7) 
    iPhone Simulator: 
    4,3: (8H7) 
+0

可能你有一个隐形字符插入到你正在处理的文件。重新定义属性。 – CodaFi 2013-04-22 04:09:45

+4

更新您的Xcode版本。我不相信4.1支持引入strong关键字的ARC。 – 2013-04-22 04:19:18

回答

7

强大的性能是FE自Xcode 4.2(LLVM编译器3.0)以来可用的ARC(自动引用计数),比较https://developer.apple.com/library/ios/releasenotes/ObjectiveC/ObjCAvailabilityIndex/index.html

+0

好的,谢谢!我现在已经Xcode 4.6.2!但是我收到以下错误:'在强壮之前预期属性属性'。我已经看到它可能是可能过时的编译器。但我对XCode很陌生,对此我有点困惑。谢谢 ! – Reveclair 2013-04-22 08:22:12

+0

@Reveclaire:可能你必须将该项目转换为ARC:编辑 - >重构 - >转换为Objective-C ARC ... – 2013-04-22 08:29:12

+0

好吧,工作!谢谢 ! – Reveclair 2013-04-22 14:44:23

0

你实际使用ARC吗?创建项目时是否勾选了“使用自动引用计数”复选框?如果你使用旧版本的XCode,那么你不会得到这样的选项,因为它不支持ARC。在这种情况下,或者更新你的xcode,或者在没有ARC的情况下继续使用手动内存管理和关键字,如'assign/nonassign'而不是'strong/weak'...