any ideas why am I getting an "unknown type name NSManagedObjectContext" in this code?
I'm basically adding core data to an existing project. I've added the coredata lines + I have added in the CoreData.framework to the project. To do this I went:
Note sure what else I have to do? The CoreDataBooks example code that looks pretty much the same as what I have seems to compile
#import <UIKit/UIKit.h>
@interface myAppAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
UINavigationController *navigationController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
// Core Data
@property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext; // ERROR: unknown type
@property (nonatomic, retain, readonly) NSManagedObjectModel *managedObjectModel; // ERROR: unknown type
@property (nonatomic, retain, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator; // ERROR: unknown type
- (void)saveContext;
- (NSURL *)applicationDocumentsDirectory;
@end
You then have to import the Core Data framework headers into any files that use Core Data classes.
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With