2013-04-22 101 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'...