2010年4月30日金曜日

NSPredicate メモ

コード:

NSDictionary *d0= [NSDictionary dictionaryWithObjectsAndKeys:@"val10", @"key0", nil];
NSDictionary *d1= [NSDictionary dictionaryWithObjectsAndKeys:@"val11", @"key0", nil];
NSDictionary *d2= [NSDictionary dictionaryWithObjectsAndKeys:@"val02", @"key0", nil];
NSArray *anArray= [NSArray arrayWithObjects:d0, d1, d2, nil];
NSArray *result= [anArray filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"key0 CONTAINS %@", @"al1"]];
NSLog(@"%@", result);


結果:

(
{
key0 = val10;
},
{
key0 = val11;
}
)

0 件のコメント: