• 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
NSMenuItem & NSRuleEditor
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSMenuItem & NSRuleEditor


  • Subject: NSMenuItem & NSRuleEditor
  • From: Jon Hull <email@hidden>
  • Date: Sat, 26 Sep 2009 13:09:34 -0700

I must be missing something in the documentation. I am trying to populate a Rule Editor with choices from a plist file. The plan is to create and return an NSMenuItem for each string stored in the corresponding spot in a plist. Here is what IS working:
• I can get the NSRuleEditor to display menuItems from a popup loaded from the XIB (as in the example I found)
• I can load in the plist and confirm that the resulting dictionary/ array structure as well as the return values for the #ofChildren method are correct


But when I create an NSMenuItem programmatically instead of grabbing a pre-made one, no menu shows up in the rule editor (only blank rows)...

I have tried disconnecting this from my data structure and just creating a fixed item with the same effect. I can only assume I am creating the NSMenuItem incorrectly.

Here is the relevant code: (please excuse the lack of type checking & other error code... it will be added once I get it working... I have checked the debugger and the types are correct)

-(NSMenuItem*)menuItemForKey:(NSString*)key index:(NSUInteger)index
{
if(key==nil)
return nil;
NSArray *children = [plistDictionary objectForKey:key];// plistDictionary contains a tree of children
NSString *title = [children objectAtIndex:index];
if([title isEqualToString:@"-"])
return [NSMenuItem separatorItem];
return [[[NSMenuItem alloc]initWithTitle:title action:NULL keyEquivalent:@""]autorelease];
}


- (id)ruleEditor:(NSRuleEditor *)editor child:(NSInteger)index forCriterion:(id)criterion withRowType:(NSRuleEditorRowType)rowType
{
NSString *key;
if (criterion) {
key = [criterion title];
}else {
key = @"Header";
}


	return [self menuItemForKey:key index:index];
}

Any help is appreciated!

Thanks,
Jon_______________________________________________

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


  • Follow-Ups:
    • Re: NSMenuItem & NSRuleEditor
      • From: Andy Lee <email@hidden>
  • Prev by Date: Re: Advice on debugging a GC related crash
  • Next by Date: Re: NSMenuItem & NSRuleEditor
  • Previous by thread: Re: Getting glyphs for surrogate characters ??
  • Next by thread: Re: NSMenuItem & NSRuleEditor
  • Index(es):
    • Date
    • Thread