将核心数据添加到app时编译器错误

Jon*_*Jon 6 iphone cocoa-touch objective-c

我正在向我的应用添加核心数据.它说,在下面的方法中Use of undeclared identifier NSSQLiteStoreType

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
    if (__persistentStoreCoordinator != nil)
    {
        return __persistentStoreCoordinator;
    }

    NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"tdfas.sqlite"];

    NSError *error = nil;
    __persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
    if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error])
    {
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }    

    return __persistentStoreCoordinator;
}

@property (nonatomic, retain, readonly) NSManagedObjectModel *managedObjectModel;
@property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, retain, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;
Run Code Online (Sandbox Code Playgroud)

Mic*_*ick 14

确保您已与CoreData链接并导入它...

#import <CoreData/CoreData.h>
Run Code Online (Sandbox Code Playgroud)

  • @Jon你可以把它添加到"支持文件"组中的-Prefix.pch文件,就在最后的#endif之前 (2认同)