Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Another newbie question



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.