I am trying to write an if statement that checks an array of objects to see if a certain object exists (in this case the word, “NBC” in my array, “channel”). I’m new to this and I’m not sure how to do it in objective c. Please take a look at my code below:
if ([[self.channel objectAtIndex:path.row] containsObject: @"NBC"])
{
//Arguments
}
After I run it with this, the simulator crashes and gives this error: 2013-01-02 17:11:44.778 Master Detail Practice App[50056:207] -[__NSCFConstantString containsObject:]: unrecognized selector sent to instance 0xc698
I know my syntax or logic is probably off. Any help will be appreciated. Thank You!
[self.channel objectAtIndex:path.row]is returning you anNSStringobject. You’re then trying to send thatNSStringinstance acontainsObject:message, which it doesn’t know what to do with. Maybe you meant:or
But without more context, it’s hard to say.