美文网首页
iOS 获取手机剩余空间和总空间

iOS 获取手机剩余空间和总空间

作者: 孤胆走天涯 | 来源:发表于2017-12-21 17:50 被阅读50次
    • (NSString *)getDivceSize{

      NSDictionary *fattributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:nil];

      NSNumber *freeber = [fattributes objectForKey:NSFileSystemFreeSize];
      NSNumber *maxber = [fattributes objectForKey:NSFileSystemSize];

      long long freespace = [freeber longLongValue];
      long long maxspace = [maxber longLongValue];

      NSString * sizeStr = [NSString stringWithFormat:@"剩余空间%0.1fG / 共%0.1fG",(double)freespace/1024/1024/1024,(double)maxspace/1024/1024/1024];
      return sizeStr;

    }

    相关文章

      网友评论

          本文标题:iOS 获取手机剩余空间和总空间

          本文链接:https://www.haomeiwen.com/subject/mpnawxtx.html