I have an array with the following elements in a method ViewDidLoad
inputArray = [NSMutableArray arrayWithObjects:@"car", @"bus", @"helicopter", @"cruiz", @"bike", @"jeep", nil];
I have another one UITextFieldto search for items. Since I find something in UITextField, I want to check if this string is present in "inputArray" or not. If it does not match the elements in inputArray, then remove the corresponding elements from inputArray.
for (NSString* item in inputArray)
{
if ([item rangeOfString:s].location == NSNotFound)
{
[inputArray removeObjectIdenticalTo:item];
NSLog(@"Contains :%@",containsAnother);
}
}
but this code shows an exception, something related to "removeobject:"
An exception:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSCFConstantString rangeOfString:options:range:locale:]: nil argument'
*** First throw call stack:
`
source
share