声明NSManagedObjectContext时出错 [英] Error when declaring NSManagedObjectContext
问题描述
我正在尝试创建一个NSManagedObjectContext对象。它们的错误内容如下:
I'm trying to create a NSManagedObjectContext object. They error reads as follows:
'NSManagedObjectContext'之前的预期说明符 - 限定符 - 列表
Expected specifier-qualifier-list before 'NSManagedObjectContext'
这是我的头文件:
#import <UIKit/UIKit.h>
@interface FavouritesViewController : UITableViewController {
NSArray *favourites;
NSManagedObjectContext *context;
}
@property (nonatomic, retain) NSArray *favourites;
@property (nonatomic, retain) NSManagedObjectContext *context;
@end
任何人都知道我可能会在这里失踪?
Anyone know I might be missing here?
推荐答案
很可能您忘记在文件中包含CoreData标头。在行 #import< UIKit / UIKit.h>
之后,你需要另一行读取 #import< CoreData / CoreData.h>
。在此之后,文件应编译正常。还要确保链接库中有CoreData,否则会出现运行时错误。
Most probably you have forgotten to include the CoreData header in your file. Right after the line #import <UIKit/UIKit.h>
you need another line that reads #import <CoreData/CoreData.h>
. After this the file should compile fine. Also make sure that you have CoreData in your linked libraries, otherwise you will get runtime errors.
这篇关于声明NSManagedObjectContext时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!