Bobby
Bobby

Reputation: 31

how to delete images / file from file system?

I get the idea of saving and loading from file system in ios from: How Can I Save This Array of Images?

can anyone tell me how to delete or remove it from file system?

Upvotes: 1

Views: 1880

Answers (2)

Basel
Basel

Reputation: 2368

You can do it using NSDefaultManager

NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];

NSString *pngFilePath = [docDir stringByAppendingPathComponent:imageName];

NSError *error;
[[NSFileManager defaultManager] removeItemAtPath:pngFilePath error:&error];

Upvotes: 10

Harshit Gupta
Harshit Gupta

Reputation: 1210

try this one:

   [[NSFileManager defaultManager] removeItemAtPath: imagePath error: nil];

Upvotes: 0

Related Questions