类扩展的语法是否已更改?

时间:2011-10-20 11:37:15

标签: objective-c xcode4.2 class-extensions

我的代码如下:

@interface InterfaceWithACategory () {
    ... Some variables
}
@end

在XCode 4.0.2中编译时,它完美无缺。

现在我对XCode 4.2 + iOS SDK 5.0进行了升级(已经将这个愚蠢的想法归咎于自己)并且出现错误“预期的标识符或'(''''''''''。'

任何帮助都会非常感激。

2 个答案:

答案 0 :(得分:1)

通常,您无法在类扩展上创建iVars,但您可以使用@property语法设置声明的属性。

@interface InterfaceWithACategory ()
@property (retain) NSArray *inDisArray;
@property (retain) NSInteger iThinkYouGetInt;
@end
在ObjC 2.1中

然而你可以这样做,但是将你的编译器设置为 Apple LLVM 3.0 我在Xcode 4.2 + iOS5.0上进行了测试,它可以工作。

答案 1 :(得分:0)

相关问题