【发布时间】:2011-12-07 17:21:37
【问题描述】:
我对 iPhone 开发非常陌生,虽然我花了几个小时寻找正确的答案,但最后却变得更加困惑。 这是我的问题 - 我正在制作一个简单的 iPhone 应用程序,它有自己的数据库/仅由一个简单的表组成,并与所有 .m 和 .h 文件/一起存储在我的项目文件夹中,并且使用托管对象模型由核心数据呈现。 我认为我按照应有的方式完成了所有操作,但我的程序以以下 “未解决的错误 Error Domain=NSCocoaErrorDomain Code=256 “操作无法完成结束。 (可可错误 256。)
其实这里是整个输出:
2011-12-07 18:50:50.009 weatherForecast[5368:207] CoreData: error: (1) I/O error for /Users/eln/Library/Application Support/iPhone 的数据库 模拟器/5.0/Applications/4991C3EB-BDC2-4507-B1FB-720F6DC30245/Documents/weatherForecast.sqlite。 SQLite 错误代码:1,'没有这样的表:Z_METADATA'
2011-12-07 18:50:50.012 weatherForecast[5368:207] 未解决的错误 Error Domain=NSCocoaErrorDomain Code=256 "无法执行该操作 完全的。 (可可错误 256。)“UserInfo=0x6a33e40 {NSUnderlyingException=数据库 I/O 错误 /Users/toma.popov/Library/Application Support/iPhone 模拟器/5.0/Applications/4991C3EB-BDC2-4507-B1FB-720F6DC30245/Documents/weatherForecast.sqlite。 SQLite 错误代码:1,'没有这样的表:Z_METADATA', NSSQLiteErrorDomain=1}, { NSSQLiteErrorDomain = 1; NSUnderlyingException = "/Users/eln/Library/Application Support/iPhone 的数据库 I/O 错误 模拟器/5.0/Applications/4991C3EB-BDC2-4507-B1FB-720F6DC30245/Documents/weatherForecast.sqlite。 **SQLite 错误代码:1, 'no such table: Z_METADATA'";
我的程序在这个 get 方法中停止: **
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if (__persistentStoreCoordinator != nil)
{
return __persistentStoreCoordinator;
}
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"weatherForecast.sqlite"];
NSLog(@"DATABASE IS LOCATED AT: %@",(NSString *)[self applicationDocumentsDirectory]);
NSError *error = nil;
__persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error])
{
//right here my program aborts
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
**
如果有人给我建议或至少对可能出现的问题提出建议,我将不胜感激。提前致谢!
【问题讨论】:
标签: cocoa-touch core-data