Re: NSPredicateEditorTemplateRow , pop up with Core Data objects
Re: NSPredicateEditorTemplateRow , pop up with Core Data objects
- Subject: Re: NSPredicateEditorTemplateRow , pop up with Core Data objects
- From: Daniel Vollmer <email@hidden>
- Date: Sun, 12 Apr 2009 17:22:47 +0200
Hello,
On Apr 10, 2009, at 23:37 , Dan Waltin wrote:
I'm trying to create a NSPredicateEditorTemplateRow where the last
view is a popup, containing every item of a particular CoreData
entity (named StudyVisit).
I'm doing something similar (and it's working fine for me).
Then I override the templateViews method, as follows:
- (NSArray *)templateViews
{
NSArray *parentViews = [super templateViews];
NSMenu *menu = [[parentViews objectAtIndex:2] menu];
if (studyVisitsController != nil)
{
for (id studyVisit in [studyVisitsController arrangedObjects])
{
[menu addItemWithTitle:[studyVisit valueForKey:@"title"]
action:nil keyEquivalent:@""];
}
}
return parentViews;
}
One possible pitfall I can think of is that studyVisitsController is
indeed nil (e.g. directly after unarchiving). To force the
predicateEditor to recreate its internal views / structures, I save
its rowTemplates, set them to nil, and set them back to the original
array once all the connections are valid (i.e. windowDidLoad for me).
If you want to use more of the superclass-functionality, also make
sure to set the representedObject of the menu-items to the value you
want represented (e.g. [NSExpression
expressionForConstantValue:<value>].
Last but not least, did you implement copyWithZone: so that copies of
the template also have the controller?
HTH,
Daniel.
_______________________________________________
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