美文网首页
iOS开发_获取设备的总容量/可用容量

iOS开发_获取设备的总容量/可用容量

作者: 代码守望者 | 来源:发表于2016-09-19 11:55 被阅读128次
    361bef6c5d205af78b9561fa0e9f1370.jpg

    如何获取设备的总容量(k为单位)

    + (NSNumber *)totalDiskSpace
    {
    
      NSDictionary *fattributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:nil];
    
      return [fattributes objectForKey:NSFileSystemSize];
    
    }
    

    如何获取设备的可用容量(k为单位)

    + (NSNumber *)freeDiskSpace
    {
        NSDictionary *fattributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:nil];
    
        return [fattributes objectForKey:NSFileSystemFreeSize];
    
    }

    相关文章

      网友评论

          本文标题:iOS开发_获取设备的总容量/可用容量

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