I want to check if my NSString 'name' contains "Brittany" or "Bob", but the following code doesn't seem to do the trick?
ViewController.m
NSPredicate *p = [NSPredicate predicateWithFormat:@"name contains[cd] %@ OR name contains[cd] %@", @"Brittany", @"Bob"];
NSArray *filtered = [self.messages filteredArrayUsingPredicate:p];
Any idea what this should look like instead? I can't seem to get the syntax right. The issue is that 'filtered' is not returning the arrays in which string name containing "Bob", just the ones in which name contains "Brittany".
Here is what self.messages contains:
This is the messages data (
{
body = "Hi";
endswaptime = "<null>";
"first name" = Brittany;
name = Brittany;
nid = 1803;
"node_title" = "Re:";
},
{
body = "It is brittany";
endswaptime = "<null>";
"first name" = Brittany;
name = Brittany;
nid = 1804;
"node_title" = "Re:";
},
{
body = "Hellooo :)\n";
endswaptime = "<null>";
"first name" = Bob;
name = "Bob";
nid = 1805;
"node_title" = "Re:";
}
)