I am working on an iPhone app where I am giving the option to download an image on the user's iPhone. My code is below to download the image.
UIImage * image = [[UIImage alloc] initWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: urlAddress]]]; NSString * pngFilePath = [[[NSString stringWithFormat: @ "% @ /", docDir] stringByAppendingString: [NSString stringWithFormat: @ "% @", coupon id] stringByAppendingString: @ ".png"]; NSDT * Data1 = [NSDATA DataWidth Data: UIMJPNGERPanation (Image)]; [Data1 writeToFile: pngFilePath atomically: Yes];
The above code works fine but now I want to give the option to delete the downloaded image from the above code. Can someone advise me how can I remove an image file from the iPhone?
You can use the removeItemAtPath method:
NSFileManager * fileManager = [NSFileManager defaultManager]; [File Manager Removedemet path: pngFilePath error: NULL];
Return value
Yes, if the removal process succeeds, if the operation is not successful, but the representative
Yes Yes to the file manager Yes: should appear in the ProApprewerAir: RemovingTime ATAPHETH:
message,removeItemAtPath: error:
alsoYES
. Otherwise this method returnsnot
Comments
Post a Comment