views:

57

answers:

1

In my app I create and use a normal persistent store:

- (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;

..nothing special. It contains several NSData objects - all core data compliant on iPhone and iPAD.

I create the file on the iPhone and would like to copy it to the iPAD. When I open the same app on the iPAD it uses the copied sqlite and works fine as long as it reads/fetches. As soon as I change the data and need to store back I get the following error:

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;

Currently I use iPhoneExplorer and just drag the file from iPhone -> MAC -> iPAD. I checked the rw Attributes with iFile and they are rw for the user on the iPAD. (same as on iPhone)

What could be the problem here and how can I solve this?

+1  A: 

iPhoneExplorer is not supported by Apple and "just drag[ging] the file from iPhone -> MAC -> iPAD" is not supported. If you want to include the file on your iPad application then include it as part of the bundle or use another mechanism to transfer the file.

Marcus S. Zarra
Exactly. Don't bother with a third-party tool and just use the file sharing support via iTunes that OS 3.2+ gives you. Then you can just drag the file into the application's Documents directory via iTunes.
Brad Larson
Thanks for the advice - it's a good idea. However, I need to figure out how to register my app as being one where the user can exchange file first. I don't know how to do that.In the meanwhile - I found the solution! Just check the owner of the file and set it to mobile instead of root - using iFile. Now it works. -> Fast fix for testing!
Then you should probably delete this question.
Marcus S. Zarra