Le 26 mai 2010 à 16:42, Graham Cox a écrit : > > On 27/05/2010, at 12:35 AM, Keary Suska wrote: > >> Not enough info: are you using Core Data, or a simple modeled relationship? >> I assume the issue is about traversing a relationship--otherwise the >> solution is trivial... > > > No, it's a simple 'to many' property in my own model, not using Core Data. If > it's trivial I can't find the solution - I have tried many things hinted at > by the predicates guide. I am tired having worked a 14 hour day and counting, > so perhaps I just need a rest to see the wood for the trees... > > I have a list of objects. Each object has a 'categories' property, which is > another 'to many' property, i.e. a list. Each category has a simple 'name' > property. > > I desire to match a string I enter to any of the categories.name strings in > the list using equals, begins with, ends with, contains. I'm setting up the > predicate editor in IB, but I can't see any way to use the aggregating > predicate syntax anywhere there and when I attempt it I get a runtime error > (e.g. no value for key 'ANY categories'). > > Perhaps it's a limitation of IB that more complex predicate editor row > templates are not available?
I had a similar problem (perhaps not exactly the same). I resolve it by subclassing NSPredicateEditorRowTemplate. Then in IB select the predicate row template and set its class to your subclass. Here is my code : @interface RBDAnyPredicateEditorRowTemplate : NSPredicateEditorRowTemplate { } @end @implementation RBDAnyPredicateEditorRowTemplate - (NSPredicate *)predicateWithSubpredicates:(NSArray *)subpredicates { /* we only make NSComparisonPredicates */ NSComparisonPredicate *predicate = (NSComparisonPredicate *)[super predicateWithSubpredicates:subpredicates]; /* construct an identical predicate, but set the modifier to NSAnyPredicateModifier flag */ return [NSComparisonPredicate predicateWithLeftExpression:[predicate leftExpression] rightExpression:[predicate rightExpression] modifier:NSAnyPredicateModifier type:[predicate predicateOperatorType] options:[predicate options]]; } @end I did something similar to have a boolean predicate. Frédéric_______________________________________________ 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