开发者

UIImagePicker URL convert for attributesOfItemAtPath iOS

开发者 https://www.devze.com 2023-03-20 12:37 出处:网络
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 cl

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消