objective c - iPhone - Free space left on device reported incorrectly (+- 200 Mb difference) -
i use method free space on disk, extracted code found after 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, gives me free space of 3660062720.000000 bytes give 3,408699035644531 gb (/1024/1024/1024)
but looking iphone setting -> general info (and itunes), i'm said iphone has 3.2 gb left.
where mistake ?
it appears free space reported incorrectly https://discussions.apple.com/thread/2566412?threadid=2566412
edit: tried following code , noticed on device, there ~200mb discrepancy. maybe storage reserved system somehow?
nsdictionary *fsattr = [[nsfilemanager defaultmanager] filesystemattributesatpath:nshomedirectory()]; unsigned long long freespace = [[fsattr objectforkey:nsfilesystemfreesize] unsignedlonglongvalue]; nslog(@"%llu", freespace); nslog(@"%f", freespace / 1073741824.0);
Comments
Post a Comment