ndu*_*sis 22
使用NSFileManager类的方法
- (NSDictionary *)attributesOfItemAtPath:(NSString *)path error:(NSError **)error
Run Code Online (Sandbox Code Playgroud)
返回字典中的大小键定义为
NSString * const NSFileSize;
Run Code Online (Sandbox Code Playgroud)
举个例子
NSError *error = nil;
NSDictionary *attributes = [[NSFileManager defaultManager]
attributesOfItemAtPath:@"/path/to/file" error:&error];
if (!error) {
NSNumber *size = [attributes objectForKey:NSFileSize];
}
Run Code Online (Sandbox Code Playgroud)