I use this method to get the free space on the disk, extracted from a code found after some researches.
float freeSpace = -1.0f;
NSError* error = nil;
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSDictionary* dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error];
if (dictionary) {
NSNumber* fileSystemSizeInBytes = [dictionary objectForKey:NSFileSystemFreeSize];
freeSpace = [fileSystemSizeInBytes floatValue];
}
I wonder why when runing this, it gives me a free space of 3660062720.000000 bytes
that would give 3,408699035644531 Gb (/1024/1024/1024)
But looking into my iPhone setting -> general info (and also into iTunes), I'm said that my iPhone has only 3.2 Gb left.
Where is the mistake ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…