Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why am I getting an "unknown type name NSManagedObjectContext" in this code?

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:

  • when to application target
  • build phases
  • link binary with library
  • then added the CoreData framwork
  • then dragged it down on the project navigator so it appeared with the other framework icons in Xcode

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
like image 719
Greg Avatar asked Mar 30 '11 07:03

Greg


1 Answers

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>
like image 174
BoltClock Avatar answered Oct 30 '22 12:10

BoltClock