开发者

Why do I get this error "error: expected specifier-qualifier-list before 'NSManagedObjectContext'?

1) I have the CoreData.framework imported. In Groups & Files I see it in the Framworks list together with UIKit.framework, Foundation.framework, CoreGraphics.framework.

2) I have this code, which should actually work. Don't know what that error means...

#import <UIKit/UIKit.h>
#import &开发者_开发知识库lt;CoreLocation/CoreLocation.h>

@interface RootViewController : UITableViewController <CLLocationManagerDelegate> {
    NSMutableArray *dataArray;
    NSManagedObjectContext *managedObjectContext; // HERE's THE ERROR LINE
}

Edit: After importing CoreData, the error disappeared. BUT: Actually UIKit contains it, or not??

#import <CoreData/CoreData.h>

I have an Apple example code and they NEVER import CoreData, and it works.


Apple is taking advantage of the precompiled header (.pch file). Your projects do too when you start with a template and check the "Use Core Data for storage" option.

Also, you can use the precompiled header file to add any header files you wish to import for all source files in your target and project.


You need to link the CoreData framework and import CoreData/CoreData.h in the header file. UIKit does not contain the Core Data framework.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜