2

Here i need to know the free space available in iOS device. For that i go through with many answers in stackoverflow and finally use this link,

code snippet i am using,

- (uint64_t)freeDiskspaceInphone
{
uint64_t totalSpace = 0;
uint64_t totalFreeSpace = 0;

__autoreleasing NSError *error = nil;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error];

if (dictionary) {
    NSNumber *fileSystemSizeInBytes = [dictionary objectForKey: NSFileSystemSize];
    NSNumber *freeFileSystemSizeInBytes = [dictionary objectForKey:NSFileSystemFreeSize];
    totalSpace = [fileSystemSizeInBytes unsignedLongLongValue];
    totalFreeSpace = [freeFileSystemSizeInBytes unsignedLongLongValue];
    NSLog(@"Memory Capacity of %llu GB with %llu MiB Free memory available.", (((totalSpace/1024ll)/1024ll)/1024ll), ((totalFreeSpace/1024ll)/1024ll));
} else {
    NSLog(@"Error Obtaining System Memory Info: Domain = %@, Code = %d", [error domain], [error code]);
}

return totalFreeSpace/1024/1024;
}

In this i get freespace is 978 MB but when i go to Settings --> General --> Usage in my iPad it shows like 778 MB Available (freespace). Why i get 200 MB extra where is the mistake happen?. And the device is a jailbroken whether that was the reason?

Community
  • 1
  • 1
Maniganda saravanan
  • 2,089
  • 1
  • 17
  • 32

0 Answers0