• 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: Another newbie question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Another newbie question


  • Subject: Re: Another newbie question
  • From: Erik Buck <email@hidden>
  • Date: Fri, 30 May 2008 06:05:15 -0700 (PDT)

A better subjuct might have been "How should I use interface objects to select command line arguments?" or something like that.  The current subject adds no value and will not help others search for information in the future.

  Having said that...

  One approach you might take (that will not scale to large applications that use the MVC pattern) is to store strings as the represented objects of your user interface elements.  Your code that composes the command line might look like this:

  commandString = [NSString stringWithFormat:@"runfoo %@ %@\n", [[colorPopup selectedItem] representedObject], [[sizePopup selectedItem] representedObject]];

  Use setRepresentedObject: ahead of time like this:

  [[colorPopup itemAtIndex:0] setRepresentedObject:@"-color 4"];
  [[colorPopup itemAtIndex:1] setRepresentedObject:@"-color 1"];

  [[sizePopup itemAtIndex:0] setRepresentedObject:@"-small"];

  --- or ---

  You could give each user interface item a different action and build up your command line by setting the various options in response to action messages.

_______________________________________________

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

  • Prev by Date: Re: sorting an NSTableView
  • Next by Date: Re: warning: 'NSEntityDescription' may not respond to
  • Previous by thread: Re: Another newbie question
  • Next by thread: WWDC TIcket Available
  • Index(es):
    • Date
    • Thread