-1
enter code hereIn my Application I am using Sqlite as an externel data base. So, Please Reply.I am using Xcode finding defficult to communicate to the sqlite file and Managed Object Model..


    enter code here



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

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

    NSError *error = nil;
    __persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
    if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error])
    {

  //     
         Typical reasons for an error here include:
         * The persistent store is not accessible;
         * The schema for the persistent store is incompatible with current managed object model.


        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }    

    return __persistentStoreCoordinator;
}
4

1 回答 1

1

Core Data 不打算与外部 SQLite 数据库一起使用,除非您实现自己的存储。如果您需要具有预定义架构的外部数据库,则不要尝试将 Core Data 放入您的解决方案中。而是使用标准 C API 与您的 SQLite 数据库通信。

于 2011-07-29T13:58:38.583 回答