如果textField
包含任何文本,这可以正常工作。但如果textField
为空,则不添加任何对象。
如何告诉这段代码如果textField
为空,则应将所有resultObjectsArray
对象添加到?
resultObjectsArray = [NSMutableArray array];
for(NSDictionary *object in allObjectsArray)
{
NSString *nameString = [NSString stringWithFormat:@"%@", [textField text]];
NSString *wineName = [wine objectForKey:@"Name"];
NSRange range = [wineName rangeOfString:nameString options:NSCaseInsensitiveSearch];
if ((range.location != NSNotFound))
[resultObjectsArray addObject:object];
}