我正在尝试过滤这样的对象数组:
{
"id": "0",
"title": "Crucifix and sarcophagus of Ariberto da Intimiano",
"categoryName": "COMMEMORATIVE MONUMENTS",
"audioFile": "Crucifix-and-sarcophagus-of-Ariberto-da-Intimiano",
"videoFile": null,
"textFile": "Crucifix-and-sarcophagus-of-Ariberto-da-Intimiano",
"image": "content/0/Crucifix-and-sarcophagus-of-Ariberto-da-Intimiano_flow.jpg",
"numPictures": "1",
"didascalie": ["dida 1", "dida 2", "dida 3"],
"description": "Crucifix and sarcophagus of Ariberto da Intimiano",
"link": ""
},
{
"id": "1",
"title": "The sundial of Duomo",
"categoryName": "THE SUNDIAL",
"audioFile": "The-sundial-of-Duomo",
"videoFile": null,
"textFile": "The-sundial-of-Duomo",
"image": "content/1/The-sundial-of-Duomo_flow.jpg",
"numPictures": "2",
"didascalie": ["dida 1", "dida 2", "dida 3"],
"description": "The sundial of Duomo",
"link": ""
}
NSPredicate *key1Predicate = [NSPredicate predicateWithFormat:@"title == '%@'",_searchAZ.text];
_ArtWorksTableResults = [[_ArtWorksTable filteredArrayUsingPredicate:key1Predicate] mutableCopy];
NSLog(@"%i",_ArtWorksTableResults.count);
当我执行搜索时,_ArtWorksTableResults.count
总是0
。
但是,如果我编写谓词而不是像这样使用搜索栏文本:
NSPredicate *key1Predicate = [NSPredicate predicateWithFormat:@"title == 'The sundial of duomo'"];
_ArtWorksTableResults = [[_ArtWorksTable filteredArrayUsingPredicate:key1Predicate] mutableCopy];
NSLog(@"%i",_ArtWorksTableResults.count);
_ArtWorksTableResults.count
是,这1
是正确的!
我做错了什么?
我也尝试记录搜索栏文本,一切正常。
我不明白为什么如果我直接在代码中写搜索键就可以了!