0

Need help for exit from headache... I cant able to show an image retrieve from ID3tag.

My code

         MP3InfoDictionary = (__bridge NSDictionary*)dictRef;
         if (MP3InfoDictionary != NULL) {
          NSLog(@"MP3InfoDictionary APIC %@",[MP3InfoDictionary objectForKey:@"APIC"]);

...this output in console

enter image description here

Question:how can I show the image from dictionary to an NSImage which step I must follow?

I did try every thing without success.

2rs2ts
  • 10,662
  • 10
  • 51
  • 95
sundsx
  • 588
  • 9
  • 27
  • So I haven't done enough Objective-C to give you a definite answer, but it looks like you need to take that `data` and make it an `NSData`, then use the `initWithData` method of `NSImage`. See [this answer](http://stackoverflow.com/q/5645157/691859). – 2rs2ts Feb 10 '14 at 17:11
  • ThankYou 2rs2ts for the answer... but, not so usefull for now. – sundsx Feb 10 '14 at 17:26
  • in IOS is quite simple like this: image = [UIImage imageWithData:[d objectForKey:@"data"]]; in osx imageWithData method is not available. – sundsx Feb 10 '14 at 17:28
  • I didn't say `imageWithData`, I said **`initWithData`**. – 2rs2ts Feb 10 '14 at 17:29
  • I'm pretty sure the above dump did not come from the above NSLog statement. But the dump appears to be of an NSDictionary containing an item named "APIC" which is itself an NSDictionary containing "MIME" and "data". "data" appears to be an NSData object, which can be converted to image (if it is indeed an image) using one of several techniques. – Hot Licks Feb 10 '14 at 17:30
  • (Actually, there's a 3rd dictionary -- one in the middle that has a key of "" that points to the last dictionary.) – Hot Licks Feb 10 '14 at 17:33

1 Answers1

1
NSDictionary* apic = mp3InfoDictionary[@"APIC"];  // Variables should begin with lower case
NSDictionary* nameless = apic[@""];
NSData* imageData = nameless[@"data"];
<Convert imageData to image using the method of your choice>
Hot Licks
  • 47,103
  • 17
  • 93
  • 151
  • GREAT MATE! What i miss: " But the dump appears to be of an NSDictionary containing an item named "APIC" which is itself an NSDictionary containing "MIME" and "data". "data" appears to be an NSData object," i did try convert directly from Mp3InfoDictionary key without succes. You make my days happy ThankYou! – sundsx Feb 11 '14 at 10:44
  • Careful examination of the dump is all that's required. I don't know why folks make such a big deal of it. – Hot Licks Feb 11 '14 at 12:33