My app utilizes core data. I have data source (NSMutableArray) loaded with core data records. To filter the records, I'm using textfield (JSTokenField) that has UITextField delegate in it's .m file.
When I'm filtering my search results, I'm using a simple predicate:
-(void)textFieldChanged
{
NSString *fieldText =_toField.textField.text;
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"cLastName contains[cd] %@",fieldText];
NSArray *testArr = [coreDataSource filteredArrayUsingPredicate:predicate]; //coreDataSource is my MutableArray with all core data records
NSLog(@"%@",predicate);
NSLog(@"Testarr %@",testArr);
}
NSLog returns empty array :
2013-11-05 20:53:36.765 MyApp[3045:60b] cLastName CONTAINS[cd] "a"
2013-11-05 20:53:36.766 Myapp[3045:60b] Testarr (
)
However, when I change(hard code) my predicate string like this: NSString *fieldText = @"a"; in my code, I get valid results.
2013-11-05 21:00:34.917 MyApp[3054:60b] cLastName CONTAINS[cd] "a"
2013-11-05 21:00:34.929 MyApp[3054:60b] Testarr (
"<MyUser: 0x1566fed0> (entity: MyUser; id: 0x156dbc30 <x-coredata://33798AE4-9768-4A2F-A0E8-C094F32972AD/MyUser/p5565> ; data: {\n activities = \"<relationship fault: 0x1551c540 'activities'>\";\n etc...
I'm really lost, as why doesn't it work with subclassed textfield...
btw, coreDataSource array is array of custom objects, with various properties (cLastName is one of them)
[fieldText dataUsingEncoding:NSUTF8StringEncoding], to check was is really in the string?