iphone sdk查看本地文件的大小(一个由应用程序创建) [英] iphone sdk see size of local file (one created by application)

查看:181
本文介绍了iphone sdk查看本地文件的大小(一个由应用程序创建)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有反正我可以看看应用程序创建的文件的大小,以字节为单位,然后存储该号码以后使用? OR是有任何方式,我可以告诉如果一个对象在一个NSArray是空的,我已经尝试了一切,但它只是不工作!

Is there anyway I can look at the size of a file the application creates in bytes then store that number to use later? OR is there any way I can tell if an object in an NSArray is empty, I've tried everything, but it just doesn't work!

推荐答案

使用NSFileManager类的方法

Use NSFileManager class' method

- (NSDictionary *)attributesOfItemAtPath:(NSString *)path error:(NSError **)error

返回的字典中的大小键定义为

The size key in the returned dictionary is defined as

NSString * const NSFileSize;

例如

NSError *error = nil;
NSDictionary *attributes = [[NSFileManager defaultManager] 
    attributesOfItemAtPath:@"/path/to/file" error:&error];

if (!error) {
    NSNumber *size = [attributes objectForKey:NSFileSize];
}

这篇关于iphone sdk查看本地文件的大小(一个由应用程序创建)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆