Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting file from device after using [NSData writeToFile:]

In my code I'm doing:

[anNsDataObject writeToFile:@"thefile" atomically:YES];

How can I delete this file from my device?

like image 277
Jacksonkr Avatar asked Dec 12 '22 03:12

Jacksonkr


1 Answers

Using NSFileManager's removeItemAtPath:error: method.

Example:

NSError *error;
[[NSFileManager defaultManager]removeItemAtPath:@"theFile" error:&error];

if (error)
{
  // file deletion failed
}
like image 73
Evan Mulawski Avatar answered Jan 04 '23 01:01

Evan Mulawski