2012-02-01 24 views
2

下面的代碼過濾打印下面的行:陣列與另一陣列(CS和謂詞)


TestApp[1156:207] Array: (
    "Type A" 
) 

但是不正確的。 NSPredicate應忽略區分大小寫。
有誰知道我在做什麼錯?

NSArray *array = [[NSArray alloc] initWithObjects:[[TestObject alloc] initWithType:@"Type A"], 
                 [[TestObject alloc] initWithType:@"Type B"], 
                 [[TestObject alloc] initWithType:@"Type C"], 
                 [[TestObject alloc] initWithType:@"Type D"], 
                 [[TestObject alloc] initWithType:@"Type E"], nil]; 

    NSArray *filter = [[NSArray alloc] initWithObjects:@"Type A", @"Type d", nil]; 

    NSPredicate *predicate = [NSPredicate predicateWithFormat: @"SELF.type IN[cd] %@", filter]; 

    NSLog(@"Array: %@", [array filteredArrayUsingPredicate:predicate]); 

回答