NSNull isEqualToString....

Discussion in 'iOS Programming' started by henktade, Mar 18, 2009.

  1. henktade, Mar 18, 2009
    Last edited by a moderator: Nov 22, 2012

    henktade macrumors newbie

    Jan 30, 2009
    hello guys

    I have the following code in my project which i use to copy an array to NSArray. the content come from a server using JSON.

    test.subStreams = (NSArray *)[[[feed1 valueForKey:@"product"] valueForKey:@"menu"] valueForKey:@"subMenu"];
    this works fine and I was able to check that subStreams have some values. but when ever I try to access this values I get the following runtime error.

    -[NSNull isEqualToString:]: unrecognized selector sent to instance 0xa05e5020
    any suggestion will be appreciated.
  2. HiRez macrumors 603


    Jan 6, 2004
    Western US
    What type of objects are in the array? Strings? Are they NSStrings? Can you post the code you're using to test accessing the objects? You say you've confirmed that subStreams have values but then you say you can't access the values so I'm a little confused. In any case it seems some value is null, so I don't think your array got populated correctly with valid Objective-C objects. What you might need to do is loop through the returned JSON list and create an NSString for each item, then add it to the array.
  3. kainjow Moderator emeritus


    Jun 15, 2000
    I'm guessing you're using some third-party JSON code and are either running into a bug in the code, or running into an NSNull object and you're assuming it's something else. Check the return values of each of the valueForKey: methods instead of assuming each object is valid.

Share This Page