假设我需要将许多图像写入iPhone文件系统。我需要找到足够的空间将图像写入磁盘。可以使用iPhone SDK吗?
对的,这是可能的。请参阅以下教程(使用强大的“google”搜索引擎找到);)
http://iphoneincubator.com/blog/device-information/how-to-obtain-total-and-available-disk-space-on-your-iphone-or-ipod-touch
编辑:添加了回复:将 UIImage 写入磁盘,可用磁盘空间未知:
尝试找出不好的做事方式。可可中的例外情况仅适用于真正的例外情况(即值得崩溃的情况)。如果您使用以下方式编写图像
NSData *imageData = [myImage UIImageJPEGRepresentation];
(或 UIImagePNGRepresentation)
and then
NSError *error;
BOOL success = [imageData writeToFile:(NSString *)path options:(NSDataWritingOptions)mask error:&error];
Your BOOL
failed
会告诉你它是否有效,并且error
将包含一个NSError
带有错误描述的对象(不要测试error != nil
不过,偶尔会崩溃)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)