I-Phone: Trying to check an Array for an item based on a string produced
- by MB
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