I'm new in objective-c. I have a path to file contained in an NSString and I want get file size. I found this example and change deprecated code with attributesOfItemAtPath:error: but path is always invalid.
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSString *path = @"~/Library/Safari/History.plist";
NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath: path error: NULL];
if (fileAttributes != nil) {
NSNumber *fileSize;
if (fileSize == [fileAttributes objectForKey:NSFileSize]) {
NSLog(@"File size: %qi\n", [fileSize unsignedLongLongValue]);
}
}
else {
NSLog(@"Path (%@) is invalid.", pPath);
}
[NSFileManager release];