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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to