title: Issue with a block and waiting for it to finish
body: <p>i'm retrieving an image with UIImagePickerController and i need to check if it has gps metadata in it or not. this code will pull it out but i'm having an issue with timing with the block. Since i'm using a block on the assetLibrary, it will complete at a later time (abit, fractions of a second).</p>
  
  <pre><code>if ([info objectForKey:UIImagePickerControllerReferenceURL])
  {
      [self performSelectorOnMainThread:@selector(testMethod:) withObject:[info objectForKey:UIImagePickerControllerReferenceURL] waitUntilDone:YES];
  
      NSLog(@"self.metadataDictionary back in impagepickerdidfinish: %@", self.metadataDictionary);
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>-(void)testMethod:(NSURL *) photoURL
  {        
          ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
  
          [library assetForURL:photoURL resultBlock:^(ALAsset *asset) {
              ALAssetRepresentation *representation = [asset defaultRepresentation];
              NSDictionary *metadataDict = [representation metadata]; 
              self.metadataDictionary = metadataDict;
              NSLog(@"self.metadataDictionary in block: %@", self.metadataDictionary);
  
          } failureBlock:^(NSError *error) {
              NSLog(@"%@",[error description]);
          }];
  }
  </code></pre>
  
  <p>the line </p>
  
  <pre><code>NSLog(@"self.metadataDictionary back in impagepickerdidfinish: %@", self.metadataDictionary);
  
  2012-03-21 16:40:47.110[9387:707] self.metadataDictionary back in impagepickerdidfinish: (null)
  2012-03-21 16:40:47.265[9387:707] self.metadataDictionary in block: {
      ColorModel = RGB;
  }
  </code></pre>
  
  <p>runs before the block is complete and logs as (null).</p>
  
  <p>i thought calling it on the main thread would make it wait until the block was finished, but it doesn't.</p>
  
  <p>any ideas how i can get the app to wait till the block is complete?</p>