Iphone get free space

I use this method to get the free space of the device (find it on the network):

-(float)getFreeSpace{  
float freeSpace = 0.0f;  
NSError *error = nil;  
NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:kSongsFolder error: &error];  

if (dictionary) {  
    NSNumber *fileSystemFreeSizeInBytes = [dictionary objectForKey: NSFileSystemFreeSize];  
    NSLog(@"%d",fileSystemFreeSizeInBytes);
    freeSpace = [fileSystemFreeSizeInBytes floatValue];  
} else { 
    //Handle error
}  
return freeSpace/1024; 

}

now I get 8687616.0 from this method, and when I check the properties of the device, I have 8.1 GB for free.

How can I get free space in MB? and this method was good because there is something else between them.

+3
source share
2 answers
fileSystemFreeSizeInBytes/(1024 * 1024) gives you size in MB
+4
source

the size is in KB, you will have to divide it again by 1024. and if you need it in GB, then divide by 1024 again

0
source

All Articles