title: iOS AVFoundation: How do I fetch artwork from an mp3 file?
body: <p>My code:</p>
  
  <pre><code>- (void)metadata {
  AVURLAsset *asset = [AVURLAsset URLAssetWithURL:self.fileURL options:nil];
  
  NSArray *artworks = [AVMetadataItem metadataItemsFromArray:asset.commonMetadata withKey:AVMetadataCommonKeyArtwork keySpace:AVMetadataKeySpaceCommon];
  NSArray *titles = [AVMetadataItem metadataItemsFromArray:asset.commonMetadata withKey:AVMetadataCommonKeyTitle keySpace:AVMetadataKeySpaceCommon];
  NSArray *artists = [AVMetadataItem metadataItemsFromArray:asset.commonMetadata withKey:AVMetadataCommonKeyArtist keySpace:AVMetadataKeySpaceCommon];
  NSArray *albumNames = [AVMetadataItem metadataItemsFromArray:asset.commonMetadata withKey:AVMetadataCommonKeyAlbumName keySpace:AVMetadataKeySpaceCommon];
  
  AVMetadataItem *artwork = [artworks objectAtIndex:0];
  AVMetadataItem *title = [titles objectAtIndex:0];
  AVMetadataItem *artist = [artists objectAtIndex:0];
  AVMetadataItem *albumName = [albumNames objectAtIndex:0];
  
  if ([artwork.keySpace isEqualToString:AVMetadataKeySpaceID3]) {
      NSDictionary *dictionary = [artwork.value copyWithZone:nil];
      self.currentSongArtwork = [UIImage imageWithData:[dictionary objectForKey:@"data"]];
  }
  else if ([artwork.keySpace isEqualToString:AVMetadataKeySpaceiTunes]) {
      self.currentSongArtwork = [UIImage imageWithData:[artwork.value copyWithZone:nil]];
  }
  
  self.currentSongTitle = [title.value copyWithZone:nil];
  self.currentSongArtist = [artist.value copyWithZone:nil];
  self.currentSongAlbumName = [albumName.value copyWithZone:nil];
  self.currentSongDuration = self.audioPlayer.duration;
  }
  </code></pre>
  
  <p>This works for fetching artwork from m4a files, but doesn’t work for mp3 files. If the <code>asset</code> points to an mp3 file, <code>artworks</code> is empty. What am I doing wrong and how do I fix it?</p>