How to save Flickr images to files on Cocoa Touch
I am getting a photosets from flickr anyone know how to save or export an image to file on iphone afer getting pics from开发者_如何学编程 flickr
Do you mean to store the images offline on the device? You could save it into the documents directory of your app on the device.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"savedImageName.png"];
//Assume you have the imageData from the url connection you used to downlod
[imageData writeToFile:savedImagePath atomically:NO];
To save a photo to the camera roll call the function:
UIImageWriteToSavedPhotosAlbum(myImage, nil, nil, nil); //myImage is a UIImage
Provide nil for the last three arguments unless you want to be notified of when the image has finished saving. In this case, the arguments and their types are:
UIImage *image,
id completionTarget,
SEL completionSelector,
void *contextInfo
More details of this function are in the UIKit Function Reference.
精彩评论