UIImagePicker URL convert for attributesOfItemAtPath iOS
I've been trying to figure out how to convert a "开发者_运维百科UIImagePickerControllerReferenceURL" into a path that I can use to call the "attributesOfItemAtPath" method of the NSFileManager class.
I tried [NSURL path], but it doesn't convert it into a directory path that the NSFileManager can understand...
Is there some way to do this, or maybe another way of getting the actual path of the file picked with UIImagePicker?
What you get is an Assets Library URL. You can use this to get the asset
object which you can use to gather relevant information.
ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
[library assetForURL:theAssetURL
resultBlock:^(ALAsset * asset) {
/* Use the "asset" object to get the details */
}
failureBlock:^(NSError * error) {
/* Error retrieving the asset */
NSLog(@"%@", [error localizedDescription]);
}];
You can look at the valueForKey:
and defaultRepresentation
methods.
精彩评论