如何查看应用程序创建的文件的大小(以字节为单位)?
使用 NSFileManager 类的方法
- (NSDictionary *)attributesOfItemAtPath:(NSString *)path error:(NSError **)error
返回的字典中的size键定义为
NSString * const NSFileSize;
举个例子
NSError *error = nil;
NSDictionary *attributes = [[NSFileManager defaultManager]
attributesOfItemAtPath:@"/path/to/file" error:&error];
if (!error) {
NSNumber *size = [attributes objectForKey:NSFileSize];
}