I am using this method to get the device free space(found it in web):
-(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 from this method 8687616.0 and when i check in the device properties i have a 8.1 GB free.
how can i get the free space in MB? and did this method good,because there is a different between them.
1 Answer