繁体   English   中英

iOS中objective-c中的属性错误

[英]error with property in objective-c in iOS

我已经启动了新的iOS项目,并在ViewControler头文件中仅添加了一个属性。 但这给了我错误:

“属性”之前的预期specifier-qualifier-list

这是代码:

#import <UIKit/UIKit.h>

@interface QuoteGenViewController : UIViewController {

    @property (retain) NSArray *myQuotes;
}

@end

这里是类接口的一般结构

@interface Class : Superclass
{
    // Instance variable declarations.
    // Theirs definition could be omitted since you can declare them
    // in the implementation block or synthesize them using declared properties.
}
// Method and property declarations.
@end

由于属性提供了一种简单的方法来声明和实现对象的访问器方法(getter / setter),因此需要将它们放在“ 方法和属性声明”部分中。

我真的建议为此阅读ocDefiningClasses文档。

希望能有所帮助。

您的代码应如下所示:

#import <UIKit/UIKit.h>

@interface QuoteGenViewController : UIViewController {

}

@property (retain) NSArray *myQuotes;

@end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM