ios获取剩下存储空间

ios获取剩余存储空间

ios获取存储空间

 
ios获取剩下存储空间转载

-(void)usedSpaceAndfreeSpace{

    NSString* path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0] ;

    NSFileManager* fileManager = [[NSFileManager alloc ]init];

    NSDictionary *fileSysAttributes = [fileManager attributesOfFileSystemForPath:path error:nil];

    NSNumber *freeSpace = [fileSysAttributes objectForKey:NSFileSystemFreeSize];

    NSNumber *totalSpace = [fileSysAttributes objectForKey:NSFileSystemSize];

   NSString  * str= [NSString stringWithFormat:@"已占用%0.1fG/剩余%0.1fG",([totalSpace longLongValue] - [freeSpace longLongValue])/1024.0/1024.0/1024.0,[freeSpace longLongValue]/1024.0/1024.0/1024.0];

    NSLog(@"--------%@",str);

}



 

2014-1-23 10:55:43.137 TestZouren[973:c07] --------已占用43.9G/剩余206.9G


1楼u010028869昨天 12:53
每次总结都是一次提升。加油!