title: Retrieving the key name on AVMetadataItem for an AVAsset in iOS
body: <p>I am trying to identify the different metadata items on a video on the iPad. So far I was able to successfully use the AVAsset libraries to find the file, and generate an array of AVMetadataItems using <code>metadataForFormat:</code>. Only iTunes and Quicktime User data formats were found in the file. The issue is now that I have that information, I have no way of identifying what is what. I intended to load a dictionary with the information, indexed by the metadata key, but using the <code>key</code> property of AVMetadataItem appears not to work correctly as if returns a number (debugger says its an NSCFNumber). Here is some sample code of what I am doing:</p>
  
  <pre><code>ALAssetRepresentation *representation = [[valAsset defaultRepresentation] retain];
  NSURL *url = [representation url];
  AVURLAsset *aAsset = [[AVURLAsset URLAssetWithURL:url options:nil] retain];
  metaDataDict = [[NSMutableDictionary dictionary] retain];
  NSArray *fmtmetadata = [aAsset metadataForFormat:@"com.apple.itunes"];
  for (AVMetadataItem* meta in fmtmetadata)
  {
      [metaDataDict setObject:[meta stringValue]
               forKey:[meta key]];
      NSLog(@"metadata: key = %@", [meta key]);
  }
  </code></pre>
  
  <p>This yields the following output in the debugger console:</p>
  
  <pre><code>metadata: key = -1452383891
  metadata: key = -1452841618
  metadata: key = 1684370275
  metadata: key = 1818518899
  metadata: key = 1937009003
  metadata: key = -1453101708
  </code></pre>
  
  <p>Incidentally, changing the NSLog line to read:</p>
  
  <pre><code>NSLog(@"metadata: %@", meta);
  </code></pre>
  
  <p>gives us output like:</p>
  
  <pre><code>metadata: keySpace=itsk, key=desc, commonKey=(null), locale=(null), value=This is the Description of the Video, time={INVALID}, duration={INVALID}, extras={
      dataType = 1;
  }
  </code></pre>
  
  <p>Any help is greatly appreciated!</p>