• 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: Possible NSPredicateEditor bug (found workaround)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possible NSPredicateEditor bug (found workaround)


  • Subject: Re: Possible NSPredicateEditor bug (found workaround)
  • From: Tom <email@hidden>
  • Date: Mon, 6 Jul 2009 09:32:32 +1000


On 03/07/2009, at 12:26 PM, Tom wrote:

Hi everyone,

I'm either doing something wrong, or I've found a bug in NSPredicateEditor.

Whenever I use setObjectValue: on the NSPredicateEditor, it displays the new predicate, but if I change a couple of the operators (is, contains, begins with, etc) the text fields on the rows disappear.

Screenshot: http://www.tomdalling.com/wp-content/Picture-1.png
Demo project: http://www.tomdalling.com/wp-content/PredicateEditorBug.zip

Here is the relevant code:

-(IBAction) setPredicateEditorObjectValue:(id)sender
{

NSPredicate* single = [NSPredicate predicateWithFormat:@"name == 'test'"];

	NSMutableArray* subpredicates = [NSMutableArray array];
	[subpredicates addObject:[[single copy] autorelease]];
	[subpredicates addObject:[[single copy] autorelease]];
	[subpredicates addObject:[[single copy] autorelease]];
	[subpredicates addObject:[[single copy] autorelease]];	

NSPredicate* compound = [NSCompoundPredicate orPredicateWithSubpredicates:subpredicates];

	[m_predicateEditor setObjectValue:compound];

}

Am I doing something wrong?

--Tom


For anyone having the same problem, here is the workaround I've discovered. It's not the most elegant solution, but it works.

1. Set the NSPredicateEditor's target/action to an IBAction on your controller
2. Put this code in the controller's IBAction method:


NSPredicate* objectValue = [[[m_predEditor objectValue] retain] autorelease];
[m_predEditor setObjectValue:nil];
[m_predEditor setObjectValue:objectValue];


--Tom






_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: 
 >Possible NSPredicateEditor bug (From: Tom <email@hidden>)

  • Prev by Date: Re: Switching Contents of NSView
  • Next by Date: Re: Switching Contents of NSView
  • Previous by thread: Possible NSPredicateEditor bug
  • Next by thread: Replace -[NSKeyedUnarchiver unarchiveObjectWithData:] so it doesn't crash on corrupt archive
  • Index(es):
    • Date
    • Thread