NSPredicate 返回空数组

NSPredicate returning empty array

我正在尝试过滤 'channels' 的数组以仅查找类型属性为 'Twitter' 的频道。但是,我尝试使用 NSPredicate returns 过滤数组为空数组。这是我的代码:

NSMutableDictionary *officials = [decodedData valueForKey:@"officials"];
NSMutableArray *channels = [officials valueForKey:@"channels"];
NSLog(@"%@", channels);


NSPredicate *twitterPredicate = [NSPredicate predicateWithFormat:@"type = 'Twitter'"];
NSLog(@"%@", [channels filteredArrayUsingPredicate:twitterPredicate]);

这是我的 return 应用谓词前后:

之前:

 (
    (
            {
        id = SenatorFeinstein;
        type = Facebook;
    },
            {
        id = SenFeinstein;
        type = Twitter;
    },
            {
        id = SenatorFeinstein;
        type = YouTube;
    }
),
    (
            {
        id = senatorboxer;
        type = Facebook;
    },
            {
        id = SenatorBoxer;
        type = Twitter;
    },
            {
        id = SenatorBoxer;
        type = YouTube;
    }
),

)

之后:

2015-01-07 10:19:31.760 voices[537:66850] ()

我的谓词过滤器有问题吗?我正在为 iOS 使用 Google Civic API。任何建议表示赞赏

试试这个,它会从通道数组中的数组中获取所有字典:

NSMutableDictionary *officials =[decodedData valueForKey:@"officials"];
NSMutableArray *channels = [officials valueForKey:@"channels"];
NSLog(@"%@", channels);

NSMutableArray *onlyChannels = [[NSMutableArray alloc] init];
for (NSArray *array in channels)
{
    for (NSDictionary  *dict in array)
    {
        [onlyChannels addObject:dict];
    }
}


NSPredicate *twitterPredicate = [NSPredicate predicateWithFormat:@"type = 'Twitter'"];
NSLog(@"%@", [onlyChannels filteredArrayUsingPredicate:twitterPredicate]);