我正在创建一个iphone性能应用程序,我想知道iPhone上的磁盘空间......我知道很多应用程序都这样做但我似乎无法在任何地方找到它
答案 0 :(得分:4)
+(float)getTotalDiskSpaceInBytes {
float totalSpace = 0.0f;
NSError *error = nil;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error];
if (dictionary) {
NSNumber *fileSystemSizeInBytes = [dictionary objectForKey: NSFileSystemSize];
totalSpace = [fileSystemSizeInBytes floatValue];
} else {
DLog(@"Error Obtaining File System Info: Domain = %@, Code = %@", [error domain], [error code]);
}
return totalSpace;
}