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' needssetScrollViewneed 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)
4

2 回答 2

7

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

于 2013-04-22T04:26:07.507 回答
0

你真的在使用 ARC 吗?您在创建项目时是否勾选了“使用自动引用计数”复选框?如果您使用旧版本的 XCode,那么您将不会获得这样的选项,因为它不支持 ARC。在这种情况下,要么更新您的 xcode,要么继续使用手动内存管理和关键字(例如“分配/非分配”而不是“强/弱”)而不使用 ARC...

于 2013-04-22T07:34:22.333 回答