iphone - Bytes to KiloBytes -
i retrieving size of files in document directory. using method attributesofitematpath
so. successful. getting output in form of bytes , of class nsnumber
. does'nt good.
so, need output in kbs or mbs , have convert them nsstring
in order store in nsdictionary
have display in tableview. please me so. thank you.
here code..
directorycontent = [[nsmutablearray alloc] init]; (nsstring *path in paths){ filesdictionary =[[nsmutabledictionary alloc] init]; filessize = [[nsnumber alloc] init]; filessize = [filesdictionary objectforkey:nsfilesize]; filesdictionary = [nsdictionary dictionarywithobjectsandkeys:filessize, @"filessize", nil]; [directorycontent addobject:[filesdictionary copy]]; }
and using following code bind size in tableview not working.
cell.lblsize.text = (nsstring *) [[directorycontent objectatindex:listindex] objectforkey:@"filessize"];
help me convert size of file byte kilobyte , display in tableview. thank in advance..
rounded nearest kb:
nsnumber *filesize = [[directorycontent objectatindex:listindex] objectforkey:@"filesize"]; cell.lblsize.text = [nsstring stringwithformat: @"%d", (int)round([filesize doublevalue] / 1024]);
Comments
Post a Comment