Do not detect disk space on iPhone SDK

Suppose I need to write many images to the iPhone file system. And I need to find that I have enough space to write the image to disk. Can I use the iPhone SDK?

+4
source share
2 answers

Yes it is possible. See the next tutorial (found using the powerful Google search engine);)

http://iphoneincubator.com/blog/device-information/how-to-obtain-total-and-available-disk-space-on-your-iphone-or-ipod-touch

Edit: added answer re: writing UIImage to a disk with unknown disk space:

Try-catch a bad way of doing something. Exceptions from cocoa relate only to truly exceptional circumstances (i.e. errors). If you are writing your image using

NSData *imageData = [myImage UIImageJPEGRepresentation]; 

(or UIImagePNGRview)

and then

 NSError *error; BOOL success = [imageData writeToFile:(NSString *)path options:(NSDataWritingOptions)mask error:&error]; 

Your BOOL failed will tell you if it works, and error will contain an NSError object with a description of the error (do not check error != nil , although this may cause a failure).

+5
source

All Articles