iphone: NSDATA dataWithContentsOfURL returning null
I have a problem of getting NSData via [NSData dataWithContentsOfURL: url]
and giving me an null object where the url is the NSURL got it from defaultRepresentation
of the asset.. The url in the NSURL is :
assets-library://asset/asset.JPG?id=1000000366&ext=JPG
I went to other forum, they talked about something like file url... Do I have to convert the url to file path ?
But i can have the thumbnail of the ALAsset on a view.
Does anyone know why i get null NSData obje开发者_如何学Cct?
from what I know these URLs are just for identification or so - you cannot actually access them.
maybe this helps ? ALAsset , send a photo to a web service including its exif data
If what you're after is the image, you could do something like this...
ALAssetsLibrary *library = [[[ALAssetsLibrary alloc] init] autorelease];
NSURL *yourAssetUrl = ;//Insert Your ALAsset's URL here
[library assetForURL:yourAssetUrl resultBlock:^(ALAsset *asset) {
if (asset) {
ALAssetRepresentation *imgRepresentation = [asset defaultRepresentation];
CGImageRef imgRef = [imgRepresentation fullScreenImage];
UIImage *img = [UIImage imageWithCGImage:imgRef];
CGImageRelease(imgRef);
[self doSomethingWithImage:img];
}
} failureBlock:^(NSError *error) {
}];
精彩评论