Note that there are some explanatory texts on larger screens.

plurals
  1. POcopyItemAtPath works on simulator but fails on device
    text
    copied!<p>I have this code that copy a .txt file from main bundle to documents dir. This works on simulator but fails to work on Device. I verify that it works on Simulator by deleting the txt file in documents dir and running the app again. When I run the app on the Device, copyItemAtPath failed. here's my code.</p> <pre><code> BOOL success; NSFileManager *fileManager = [NSFileManager defaultManager]; NSError *error; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *writableDBPath= [documentsDirectory stringByAppendingPathComponent:@"zipFileName.txt"]; success = [fileManager fileExistsAtPath:writableDBPath]; if (success) { return; } // The writable database does not exist, so copy the default to the appropriate location. NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"zipFileName.txt"]; success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&amp;error]; if (!success) { NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]); } </code></pre> <p>I tried cleaning and building again, i even restart the phone but nothing works.</p> <p><strong>ERROR</strong>: 2012-05-08 16:13:19.487 balita[162:707] <strong>* Assertion failure in -[ViewController currentJsonFile], /Users/diffy/Documents/balita/balita/ViewController.m:144 2012-05-08 16:13:19.496 balita[162:707] <em></strong> Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Failed to create writable database file with message 'The operation couldn’t be completed. (Cocoa error 260.)'.' *</em>* First throw call stack:</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload