• 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: Dynamic NSMenuItems with default param
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamic NSMenuItems with default param


  • Subject: Re: Dynamic NSMenuItems with default param
  • From: Prime Coderama <email@hidden>
  • Date: Thu, 08 Mar 2012 19:05:41 +1100

Figured it out:
> NSMenuItem *menuItem;
> menuItem = [subMenu addItemWithTitle:@"Open folder" action:@selector(openDirectory:person.directory) keyEquivalent:@""];
> [menuItem setRepresentedObject:person];

On 08/03/2012, at 6:56 PM, Prime Coderama wrote:

> I am dynamically building menu's based on an array and there is a sub-menu is linked to an IBAction which opens a folder in Finder. The folder it opens is based on a property of the object in my initial array.
>
> Is there a way of linked the NSMenuItem action to the IBAction and passing in this directory variable as I am dynamically creating this array?
>
> OR should I be going into the IBAction and resolving the directory by referencing the NSMenuItem with against array?
>
> I was thinking something along the lines of this:
> person = [[Person alloc] init];
> // person is assigned
> subMenu = [[NSMenu alloc] init];
> [subMenu addItemWithTitle:@"Open folder" action:@selector(openDirectory:person.directory) keyEquivalent:@""];

_______________________________________________

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: 
 >Dynamic NSMenuItems with default param (From: Prime Coderama <email@hidden>)

  • Prev by Date: Dynamic NSMenuItems with default param
  • Next by Date: Re: Finding object array index when iterating through array
  • Previous by thread: Dynamic NSMenuItems with default param
  • Next by thread: Re: Cocoa-dev Digest, Vol 9, Issue 161
  • Index(es):
    • Date
    • Thread