On 3 Oct 2010, at 14:29, Koh Nyap-Hong wrote:
> Hi List,
>
> I with to filter array using NSPredicate (seems a lot more easier than while loop with NSEnumerator), after read through some cocoa examples online, I run a simple test using the following codes:
>
> NSArray *pitches = [NSArray arrayWithObjects: @"Do", @"Re", @"Mi", @"Fa", @"So", @"La", nil];
>
> NSArray *filteredWithSELF = [pitches filteredArrayUsingPredicate: [NSPredicate predicateWithFormat: @"SELF == 'Do'"]];
> NSArray *filteredWithDescription = [pitches filteredArrayUsingPredicate: [NSPredicate predicateWithFormat: @"description == 'Do'"]];
> NSArray *filteredWithFormat = [pitches filteredArrayUsingPredicate: [NSPredicate predicateWithFormat: @"SELF == '%@'", @"Do"]];
>
> Out of the three predicate statements, however, the first and last one return me empty array. Only the second one returns an array containing 1 element which is the @"Do" string.
>
> Did I make any mistake in the codes, or this feature is not fully implemented yet in base-1.20?
Both ...