2011-09-21 8 views
1
[NSData dataWithContentsOfURL: url] [NSData dataWithContentsOfURL: url]를 통해 NSData를 가져 오는 중 문제가 발생하여 URL에 NSURL이있는 NSURL의 null 객체가 있습니다. NSURL의 URL은 다음과 같습니다. NSURL의 URL :

아이폰 : null을 반환하는 NSDATA dataWithContentsOfURL

assets-library : // asset/asset.JPG? id = 1000000366 & ext = JPG

다른 포럼에 가서 파일 URL과 같은 것에 대해 이야기했습니다 ... URL을 파일 경로로 변환해야합니까?

그러나보기에서 ALAsset의 축소판을 가질 수 있습니다.

아무도 왜 내가 NSData 개체 null을 알 수 있습니까?

답변

0

, 당신은 ... 이런 식으로 뭔가를 할 수

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) { 
}]; 
관련 문제