nsstring - Search through NSArray for string -
I want to search for a certain string through my NSArray. Examples:
The objects in NSArray are: "dog", "cat", "fat dog", "cheese", "one more thing", "heck here one more thing "
I want to find the word" second "and put the results in an array, and other, non-result, in another array, which can be filtered further.
Can not test, so a syntax error may occur, but you will get this idea .
NSArray * InputArere = [NSArray arrayWithObjects: @ "dog", @ "cat", @ "fat dog", @ "cheese", @ "second thing", @ "heck here More talk ", zero]; NSMutableArray * Includes Other = [NSMutableArray Array]; NSMutableArray * does notContainAnother = [NSMutableArray array]; (For NSString * item input) {if ([item rangeOfString: @ "another"]. Location! = NSNotFound) [Other addObject: item]; And no [add another item] Item:; }
Comments
Post a Comment