码迷,mamicode.com
首页 > 其他好文 > 详细

判断设备容量

时间:2014-12-09 19:43:55      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:容量

- (float)getTotalDiskSpace

{

float totalSpace;

NSError * error;

NSDictionary * infoDic = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[self getHomeDirectory] error: &error];

if (infoDic) {

NSNumber * fileSystemSizeInBytes = [infoDic objectForKey: NSFileSystemSize];

totalSpace = [fileSystemSizeInBytes floatValue]/1024.0f/1024.0f/1024.0f;

return totalSpace;

} else {

NSLog(@"Error Obtaining System Memory Info: Domain = %@, Code = %ld", [error domain], (long)[error code]);

return 0;

}

- (NSString *)getHomeDirectory

{

NSString * homePath = NSHomeDirectory();

return homePath;

}

判断设备容量

标签:容量

原文地址:http://blog.csdn.net/zh_2608/article/details/41826973

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!