tags:

views:

3261

answers:

1

Hi,

I am showing very big size images in UITableView, because of this my app is getting crashed after some time. Now i want to resize the image and save it to disk. can some one help me resizing the image from NSData/UIImage and saving saving it to the disk.

I got the code to resize the image from UIImage, so as the result i have my resized in image in UIImage object, how to save it to iphone sandbox.

Thanks,

A: 

You're asking 'how do I write a file' right?

I guess there is a touch of complication in that you probably want to write into the Library/Caches directory, so when the phone gets backed up you don't save those files.

Get the root of the app folder w/ NSHomeDirectory() and then append Library/Caches.

You can write an NSData to the fs w/ a method on NSData. If you have a UIImage, you can do UIImageJPEGRepresentation() or UIImagePNGRepresentation to get data.

Andrew Pouliot
You probably want to use NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); NSString *cachesDirectory = [paths objectAtIndex:0];Rather than appending 'Library/Caches' yourself.
Jesse Rusak