Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Get File Size (OS X) With Error Handling

By: borispio on Jan 2nd, 2012  |  syntax: Objective C  |  size: 0.37 KB  |  views: 83  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. NSError *error = nil;
  2.    
  3. NSString *path = [NSString stringWithFormat:@"%@/Library/Safari/History.plist", NSHomeDirectory()];
  4.    
  5. uint64_t fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:path error:&error] fileSize];
  6.    
  7. if (error != nil) {
  8.         NSLog(@"Error: %@", [error localizedDescription]);
  9. } else {
  10.         NSLog(@"File Size: %.0llu", fileSize);
  11. }