views:

418

answers:

2

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 <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.

+2  A: 

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

Martin Gordon
lol, I tried the same thing before reading. It works, but the strange thing is that Apple does not do so in their sample codes. They say CoreData is already imported by UIKit. Weird.
openfrog
What sample code are you looking at?
Martin Gordon
Did you check the precompiled header (.pch file) in the sample project?
gerry3
+4  A: 

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.

gerry3