Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

blueeye

macrumors member
Original poster
Oct 27, 2007
80
0
Hi all,

In developing an application which uses some XML data from a server I ran into this weird problem (weird for me, that is).
When the app launches it parses a file called rooms.xml, and then on loading a different screen it parses users.xml.
I created an XMLParser class to deal with most of this stuff, but an error is always thrown on the second parsing (both files are virtually the same but for different characters, so there's no weirdness there). The line (seems to be) here:

Code:
if([item objectForKey:currentElement] == nil) {

I checked up on item, and it is, both times around, an NSMutableDictionary, currentElement is always a string. The strangest thing is that it works for the first round of parsing but not the second...

Item should just be a dictionary containing the other elements.

Any help here would be much appreciated.:confused:

--
Sorry, forgot to put the actual error:
Code:
2009-09-28 17:04:44.812 Assisted Living 2.0[7775:207] *** -[NSCFArray objectForKey:]: unrecognized selector sent to instance 0x381f760
2009-09-28 17:04:44.812 Assisted Living 2.0[7775:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFArray objectForKey:]: unrecognized selector sent to instance 0x381f760'
2009-09-28 17:04:44.813 Assisted Living 2.0[7775:207] Stack: (
    29291611,
    2523598665,
    29673531,
    29242998,
    29095618,
    15772,
    639572,
    32764141,
    32808711,
    636751,
    15014,
    8376,
    17026,
    3241878,
    3235218,
    3277492,
    3273518,
    3279975,
    3261210,
    3282363,
    3260859,
    9983,
    3037850,
    3021016,
    274874,
    29076160,
    29072456,
    37377965,
    37378162,
    2764803
)
 
Either item is an array, not a dictionary, or you are forgetting to retain item when you create it.

I'm terribly sorry, I think I forgot to say a thank you for pointing me to the second possibility, which I think solved it.
Thanks :) Even if 'tis a bit belated.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.