0

I'm trying to get my head around parsing with SAX and thought a good place to start was the TopSongs example found at the iPhone Dev Center. I get most of it but when it comes to reaching Attributes and Values within a node I can't find a good example anywhere. The XML has a path to a URL for the coverArt. And the XML node looks like this.

<itms:coverArt height="60" width="60">http://a1.phobos.apple.com/us/r1000/026/Music/aa/aa/27/mzi.pbxnbfvw.60x60-50.jpg</itms:coverArt>  

What I've tried is this for the startElement…

 ((prefix != NULL && !strncmp((const char *)prefix, kName_Itms, kLength_Itms)) && 
        (!strncmp((const char *)localname, kName_CoverArt, kLength_Item) &&
         !strncmp((const char *)attributes, kAttributeName_CoverArt, kAttributeLength_CoverArt) &&
         !strncmp((const char *)attributes, kValueName_CoverArt, kValueLength_CoverArt) ||
         !strncmp((const char *)localname, kName_Artist, kLength_Artist) ||   

and picking it up again with just the localname at the end like this.

if (!strncmp((const char *)localname, kName_CoverArt, kLength_CoverArt)) { importer.currentSong.coverArt = [NSURL URLWithString:importer.currentString];  

The trace is -[Song setCoverArt:]: unrecognized selector sent to instance.

Jim
  • 890
  • 2
  • 10
  • 22

1 Answers1

0

Sounds like you haven't synthesized the coverArt property in your Song class (using the @synthesize keyword). That's what creates the -[Song setCoverArt:] method which is called when you set the coverArt property on currentSong.

Nathan de Vries
  • 15,481
  • 4
  • 49
  • 55
  • Thanks for your suggestion, It follows the same structure as the other nodes which are set to be @dynamic in the Song class. But I think you're right it's not getting added to the data model correctly. I've since tried adding just another node without attributes and it produced the same error result. – Jim Sep 08 '09 at 13:33
  • I hadn't added the new attribute to the Data Model file which is what threw the error. Now I have I don't get the error but I also don't get the data. So there must be something missing from the structure above. – Jim Sep 08 '09 at 18:44
  • I can reach the data as a string with a single call on the node but the problem is there are three nodes for different picture sizes. So I'm gong to still need to know how to reach the others. – Jim Sep 08 '09 at 19:19
  • Ok, I'm getting closer. I need to do a for loop to collect the right attributes. The problem now is dealing with the endelementSAX. It is still picking up all three entries even though 2 have no data. – Jim Sep 12 '09 at 00:53