Get file property
H开发者_高级运维ow to get file size of pdf,gif,doc etc using xcode. suppose to i get pdf file form resorce folder so how can i get size of for this file.
is there any way?
Thanks you,
If you want to calculate the size of your resource file in run-time basically you can do the following (omitting error checks etc):
// Get path for resource file
NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"myPDFFile" ofType:@"pdf"];
// Get file attributes
NSDictionary* attributeDict = [[NSFileManager defaultManager] attributesOfItemAtPath:resourcePath error:nil];
// Get size attribute
NSNumber* fileSizeObj = [attributeDict objectForKey:NSFileSize];
long long fileSizeVal = [fileSizeObj lonLongValue];
精彩评论