I-Phone: Trying to check an Array for an item based on a string produced
        Posted  
        
            by MB
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by MB
        
        
        
        Published on 2010-03-21T01:24:18Z
        Indexed on 
            2010/03/21
            1:31 UTC
        
        
        Read the original article
        Hit count: 473
        
Hello!
I'm writing a program that will concatenate a string based on letters, and then check an array to see if that string exists. If it does, then it will print a line in IB saying so.
I've got all the ins-and-outs worked out, save for the fact that the simulator keeps crashing on me!
Here's the code:
-(IBAction)checkWord:(id)sender
{
NSMutableArray *wordList = [NSMutableArray arrayWithObjects:@"BIKE", @"BUS", @"BILL", nil];
if([wordList containsObject:theWord])
{
NSString *dummyText = [[NSString alloc] initWithFormat:@"%@ is a real word.", theWord];
checkText.text = dummyText;
[dummyText release];
}
}
"theWord" is the string that is being referenced against the Array to see if it matches an item contained within it. In this case "BIKE" is 'theWord'.
Thank you for your help in advance!
-MB
© Stack Overflow or respective owner