Note that there are some explanatory texts on larger screens.

plurals
  1. POcrash at [NSFileManager removeItemAtPath:error:]
    text
    copied!<p>I am trying to remove a file from path using following code. But my application is crashing while removing file from the path.</p> <pre><code>- (void)saveEditedSavedFile:(NSString*)editedfile As:(NSString*)originalFile { [originalFile retain]; NSArray* dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString* docsDir = [dirPaths objectAtIndex:0]; NSError* error = nil; NSString *editedFilePath=[docsDir stringByAppendingPathComponent:editedfile]; NSFileManager* fileMngr = [NSFileManager defaultManager]; if([fileMngr fileExistsAtPath:originalFile]) { nslog(@"%@", originalFile); // nslog always prints the correct path even if it crashes.. [fileMngr removeItemAtPath:originalFile error:NULL]; } if ([fileMngr moveItemAtPath:editedFilePath toPath:originalFile error:&amp;error] != YES) { UIAlertView* alertView1 = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Unable to Save File. Please Choose a Diffrent name." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alertView1 show]; [alertView1 release]; } } </code></pre> <p>Here i am trying to replace an already existing file with a new file.(Moving a file operation) but it crashes at [fileMngr removeItemAtPath:originalFile error:NULL];</p> <p>I am getting a call stack like this ..</p> <pre><code>#0 0x99f1dc5a in __kill () #1 0x99f1dc4c in kill$UNIX2003 () #2 0x99fb05a5 in raise () #3 0x99fc66e4 in abort () #4 0x99fb4e78 in szone_error () #5 0x99fb4fb3 in free_list_checksum_botch () #6 0x99ec7a88 in small_free_list_remove_ptr () #7 0x99ec45cc in szone_free_definite_size () #8 0x99ec35e8 in free () #9 0x99ee8adb in fts_close$INODE64 () #10 0x99f31b57 in __removefile_tree_walker () #11 0x99f31999 in removefile () #12 0x0006ed01 in -[NSFilesystemItemRemoveOperation main] () #13 0x0005cbd2 in -[__NSOperationInternal start] () #14 0x0006eaa2 in -[NSFileManager removeItemAtPath:error:] () </code></pre> <p>can anyone let me know why my application is crashing? i checked that that path is coming as correct there.</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