[英]iPhone - Why am I getting this error when the view mapping is correct?
[英]Why am I getting a write error when copying a Core Data database between iPhone and iPad?
在我的應用程序中,我創建並使用普通的持久性存儲:
- (NSPersistentStoreCoordinator *) persistentStoreCoordinator {
// D_IN;
if (persistentStoreCoordinator != nil) {
return persistentStoreCoordinator;
}
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]];
// Allow inferred migration from the original version of the application.
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"Dances005.sqlite"]];
NSError *error = nil;
if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl
options:options error:&error]){
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
}
// D_OUT;
return persistentStoreCoordinator;
..沒什么特別的。 它包含幾個NSData對象-iPhone和iPAD上所有兼容的核心數據。
我在iPhone上創建了文件,並希望將其復制到iPAD。 當我在iPAD上打開相同的應用程序時,它使用復制的sqlite,並且只要讀取/獲取都可以正常工作。 一旦更改數據並需要存儲回去,我將收到以下錯誤:
Unresolved error Error Domain=NSCocoaErrorDomain Code=256 UserInfo=0x6a2b7a0 "Operation could not be completed. (Cocoa error 256.)", {
NSFilePath = "/var/mobile/Applications/294B329D-D287-4012-A551-4E7348624225/Documents/Dances005.sqlite";
NSUnderlyingException = error during SQL execution : attempt to write a readonly database;
目前,我使用iPhoneExplorer,只是從iPhone-> MAC-> iPAD拖動文件。 我用iFile檢查了rw屬性,它們是iPAD上用戶的rw。 (與iPhone相同)
這可能是什么問題,我該如何解決?
Apple不支持iPhoneExplorer,並且不支持“僅從iPhone拖動文件-> MAC-> iPAD”。 如果要在iPad應用程序中包含文件,則將其作為捆綁包的一部分包含在內,或使用其他機制來傳輸文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.