调用[MagicalRecord setupCoreDataStackWithStoreNamed]时的SIGABRT

时间:2012-07-03 19:25:18

标签: ios sigabrt magicalrecord

我是“Magical Record”的新手,对于iOS编程一般都是新手。我只是想设置好东西。我按照http://yannickloriot.com/2012/03/magicalrecord-how-to-make-programming-with-core-data-pleasant/中的说明操作,但不是:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [MagicalRecordHelpers setupCoreDataStackWithStoreNamed:@"MyDatabase.sqlite"];
    // ...
    return YES;
}

我想我正在使用更新版本将AppDelegate更改为:

@implementation LSAppDelegate
@synthesize window = _window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
    [MagicalRecord setupCoreDataStackWithStoreNamed:@"MyDatabase.sqlite"];
    return YES;
}

- (void)applicationWillTerminate:(UIApplication *)application{
    [MagicalRecord cleanUp];
}
@end

运行时,我会收到SIGABRT:

+ (NSManagedObjectModel *) MR_mergedObjectModelFromMainBundle;
{
    return [self mergedModelFromBundles:nil];
}

堆栈跟踪如下所示:

#0  0x00011f7e in +[NSManagedObjectModel(MagicalRecord) MR_mergedObjectModelFromMainBundle] at /Developer/projects/demo/MagicalRecord/Categories/NSManagedObjectModel+MagicalRecord.m:33
#1  0x00011eb4 in +[NSManagedObjectModel(MagicalRecord) MR_defaultManagedObjectModel] ()
#2  0x000147ca in +[NSPersistentStoreCoordinator(MagicalRecord) MR_coordinatorWithSqliteStoreNamed:withOptions:] ()
#3  0x000148fa in +[NSPersistentStoreCoordinator(MagicalRecord) MR_coordinatorWithSqliteStoreNamed:] ()
#4  0x00016546 in +[MagicalRecord(Setup) setupCoreDataStackWithStoreNamed:] ()
#5  0x000026eb in -[LSAppDelegate application:didFinishLaunchingWithOptions:] ()

我不知道我做错了什么或我能做些什么来解决它。有什么想法吗?

1 个答案:

答案 0 :(得分:2)

听起来您遇到了Core Data迁移问题。从模拟器中卸载应用程序将强制使用新的SQLite数据库,这在开发过程中更改模式时非常方便。

稍后,只要您创建新版本的托管对象模型,您可能希望切换到处理普通迁移的-setupCoreDataStackWithAutoMigratingSqliteStoreNamed。有关如何创建这些版本的信息,请参阅Model File Format and Versions