我有一個包含自定義類的對象的數組。然而,在初始化編譯器給我一個錯誤 - "Lexical or Preprocessor" Expected ':'
爲什麼我不能用對象初始化這個NSArray?
interface myClass : NSObject
@property (readwrite, strong) NSString* name;
@property (readwrite, strong) NSString* home;
@property (readwrite, strong) Preference pref; // This is another custom class
-(id) initWithName:(NSString*) name home:(NSString*) home preference:(Preference) preference;
end
@interface MyViewController()
@property (nonatomic, strong) NSArray *rowArray;
@end
@implementation MyViewController
...
...
...
- (void) initializeArray
{
self.rowArray = @{
[[myClass alloc] initWithName:@"Harry" home:@"New York" preference :Acura],
[[myClass alloc] initWithName:@"Win" home:@"Seattle" preference :Toyota];
};
}
誰能告訴我只是在那裏我搞亂了,爲什麼我得到這個錯誤?
接口前應該有@符號。或者是複製和粘貼錯誤? –
Yup .............. –
紐約和西雅圖不是NSStrings。 – matt