1

在我下面的项目中是字典,我有一个字典列表,我试图根据谓词获得相同的值,但我没有得到值。

    NSPredicate* searchPredicate = [NSPredicate predicateWithFormat:@"(%K CONTAINS[c] %@)",@"**equipArray.equipmentName**",textField.text];

    NSLog(@"searchPredicate %@",searchPredicate);

    NSArray* searchList = [list filteredArrayUsingPredicate:searchPredicate];

但我无法获得清单。谁能帮我 ?

    {
    equipArray =         (
                    {
            equipmentIcon = "outside.png";
            equipmentName = Outside;
        },
                    {
            equipmentIcon = "steps.png";
            equipmentName = Steps;
        },
                    {
            equipmentIcon = "partner.png";
            equipmentName = Partner;
        }
    );
    exId = 4;
    exeName = "Fireman Carry";
    exerciseAudioCue = "DG Fighting Fit-exercise_audio_test.mp3";
    exerciseDescription = "Proin gravida nibh vel velit auctor aliquet. Aenean sollicitudin, lorem quis bibendum auctor, nisi elit consequat ipsum, nec sagittis sem nibh id elit. Duis sed odio sit amet nibh vulputate cursus a sit amet mauris. Morbi accumsan ipsum velit. Nam nec tellus a odio tincidunt auctor a ornare odio. Sed non  mauris vitae erat consequat auctor eu in elit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Mauris in erat justo. Nullam ac urna eu felis dapibus condimentum sit amet a augue. Sed non neque elit. Sed ut imperdiet nisi. Proin condimentum fermentum nunc. Etiam pharetra, erat sed fermentum feugiat, velit mauris egestas quam, ut aliquam massa nisl quis neque. Suspendisse in orci enim.";
    exerciseType = Stamina;
    imageThumbNail = "firemancarry_thumbnail.png";
    longVideoName = long;
    shortVideoName = small;
}
4

4 回答 4

3

如果要查找包含给定字符串的任何元素,请使用: equipmentNameequipArray

[NSPredicate predicateWithFormat:@"ANY %K CONTAINS[c] %@", @"equipArray.equipmentName", textField.text];

(“CONTAINS”用于字符串比较,而不是检查数组中的包含。)

于 2013-06-07T11:56:18.350 回答
0

使用这个谓词:

[NSPredicate predicateWithFormat:@"equipArray.equipmentName =[cd] %@", textField.text];
于 2013-06-07T11:58:42.920 回答
0

试试这样

NSPredicate* searchPredicate = [NSPredicate predicateWithFormat:@"(equipArray.equipmentName CONTAINS[c] %@)",textField.text];
于 2013-06-07T12:01:22.780 回答
0
 NSPredicate *searchPredicate=[NSPredicate predicateWithFormat:@"ANY %K == [cd] %@", @"equipArray.equipmentName", @"steps"];
于 2013-06-07T14:05:43.877 回答