开发者

saving images to resources folder in iphone

i am downloading imag开发者_JAVA百科es from the server i would like to know whether it is possible to save those images to the resources folder of the project...if it is possible please someone explain me. Thank you


yes you can do that but resource folder is call Document Directory in iPhone and you can save anything that you want and almost all abstract data types have a method to do that name writeToFileAtPath:atomically:. // note atomically, not automatically`

You just need to pass the path of file where you want to save it.

As far as path of Document Directory is concerned its like this

[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]

this returns the path of Document Directory


NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,     NSUserDomainMask, YES);
             NSString *documentsDirectory = [paths objectAtIndex:0];
             NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"MD%d.png",y]];
             UIImage *image = imgProfile; // imgProfile is the image which you are fetching from url
             NSData *imageData = UIImagePNGRepresentation(image);
             [imageData writeToFile:savedImagePath atomically:NO]; 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜