Library image metadata

I need to get image metadata from a library. I am using code

- (void)imagePickerController:(UIImagePickerController *)picker 
didFinishPickingMediaWithInfo:(NSDictionary *)info {
   NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL];

   ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];

   [library assetForURL:assetURL resultBlock:^(ALAsset *asset) {
       ALAssetRepresentation *representation = [asset defaultRepresentation];
       metadataDict = [representation metadata]; 
       NSLog(@"%@",metadataDict);


      } failureBlock:^(NSError *error) {
       NSLog(@"%@",[error description]);
      }];
   [library release];
}

I am using iOS 4.2 but I am not getting metadata. Can someone help me with this?

+5
source share
1 answer

There is nothing wrong with the code you posted. I tried it in the simulator and on the device and it works. Apple's documentation for the method metadatareads:

Returns nil if the view is one that the system cannot interpret.

Thus, this most likely means that the image you have selected either does not have metadata, or the image is in a form that the library does not recognize.

metadataDict , , , .

metadataDict = [[representation metadata] retain];

, __block.

__block NSDictionary *metaDataDict;
+2

All Articles