Re: Predicate and beginswith
Re: Predicate and beginswith
- Subject: Re: Predicate and beginswith
- From: Joel Levin <email@hidden>
- Date: Mon, 21 May 2007 21:43:07 -0700
Hi Brian,
The following code works perfectly as expected:
NSString* arg = @"<htm";
NSMutableArray* array = [NSMutableArray array];
[array addObject:@"<html>"];
[array addObject:@"<form>"];
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"SELF
beginswith[cd] %@", arg];
NSArray* filtered = [array filteredArrayUsingPredicate:predicate];
NSLog(@"%@", array);
NSLog(@"filtered by: %@", arg);
NSLog(@"%@", filtered);
The only difference here is that in your code you are setting allKeys
back to the result of running a method on allKeys with this line:
allKeys = [allKeys
filteredArrayUsingPredicate:stringToCompletePredicate];
Try created a new array to hold the filtered array see if it makes
any difference (I'm not sure why this would be a problem, but it's
literally the only difference, so it's worth a try).
- Joel
On May 21, 2007, at 5:44 PM, Brian Amerige wrote:
Hi there list,
I've got an array (allKeys) which is filled with HTML tags --
things like "<html>", "<form>", etc.. I'm filtering it using
predicates, so I can accurately complete tags.
Here's what I've got:
NSArray *allKeys = [coloringEngine allKeys]; // this just returns
the array I mentioned above.
NSPredicate *stringToCompletePredicate = [NSPredicate
predicateWithFormat:@"SELF beginswith[cd] %@", stringToComplete]; //
stringToComplete is something like "<htm"
allKeys = [allKeys
filteredArrayUsingPredicate:stringToCompletePredicate];
But this seems to return nothing --- certainly not what I'd expect.
I expect it to return "<html>" assuming stringToComplete was
something like "<htm", but it returns an empty array.
Any suggestions?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
40gmail.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden