• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Predicate and beginswith
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Predicate and beginswith
      • From: Shawn Erickson <email@hidden>
References: 
 >Predicate and beginswith (From: Brian Amerige <email@hidden>)

  • Prev by Date: POSIX error: Broken pipe
  • Next by Date: Re: -mouseMoved: not being called
  • Previous by thread: Predicate and beginswith
  • Next by thread: Re: Predicate and beginswith
  • Index(es):
    • Date
    • Thread