• 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: Brian Amerige <email@hidden>
  • Date: Tue, 22 May 2007 10:21:17 -0400

Yep -- that's correct. My stringToComplete (the argument string) wasn't what I expected.

To give some context, this was being done in NSTextView's delegate method, textView:completions:forPartialWordRange:indexOfSelectedItem, where I was using the partialWordRange to substring the textview's textstorage's string. Typically this would be fine, but the partialWordRange does not include non alphanumeric characters --- so when the argument was really "<htm" , the substring was only "htm", which as you may guess, will return nothing under a "beginswith" query.

Thanks for the pointer to check :-)

-Brian.
On May 22, 2007, at 10:02 AM, Shawn Erickson wrote:


On May 21, 2007, at 9:43 PM, Joel Levin wrote:

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).

He is creating a new array. The allKeys lvar is storage for a pointer and it doesn't care what it points at.


To me is sounds like his [coloringEngine allKeys] is returning an array with something other then he expects or stringToComplete is nil or something other then he expects.

Brian use the debugger to understand what is going on. You can ask it to print out the description of each object to ensure it is as you expect.

-Shawn

_______________________________________________

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


References: 
 >Predicate and beginswith (From: Brian Amerige <email@hidden>)
 >Re: Predicate and beginswith (From: Joel Levin <email@hidden>)
 >Re: Predicate and beginswith (From: Shawn Erickson <email@hidden>)

  • Prev by Date: Re: NSPopUpButton Notifications
  • Next by Date: Re: NSPopUpButton Notifications
  • Previous by thread: Re: Predicate and beginswith
  • Next by thread: POSIX error: Broken pipe
  • Index(es):
    • Date
    • Thread