• 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: Extermly frustrating Problem: Feel extremly stupid, and the damn tutorials dont care.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extermly frustrating Problem: Feel extremly stupid, and the damn tutorials dont care.


  • Subject: Re: Extermly frustrating Problem: Feel extremly stupid, and the damn tutorials dont care.
  • From: j o a r <email@hidden>
  • Date: Thu, 20 Mar 2003 22:55:06 +0100

I suggest that you try to rephrase the question so that it is clear what you aim to achieve, and not how you thought you should accomplish it. It's quite likely that if you are new to Cocoa, the best way to do something might be completely different from how you first pictured it.

For example, I think that "send title as an int" sounds really suspicious. That one of the pop up menus is a controller also sounds a bit weird - but it might just be that we use different terminology.

Usually you have a controller object that is a custom subclass of NSObject, or NSWindowController. In this object you would create "action methods" that is called by the pop up buttons (I assume that you use pop up buttons, even though you only refer to pop up menus).

Something like this:

- (IBAction) popUpButtonAction:(id) sender
{
int selectedTag = [[sender selectedItem] tag];
switch (selectedTag)
{
case tagOne :
// Do something
case tagTwo :
// Do something else
}
}

Modifying a pop up button menu is usually also very simple, something like this:

- (void) addMenuItemWithTitle:(NSString *) str
{
[myPopUpButton addItemWithTitle: str];
}

- (void) addMenuItemWithSomeIntegerValue:(int) anInt
{
[myPopUpButton addItemWithTitle: [NSString stringWithFormat: @"%d", anInt]];
}

Don't give up! Read the documentation for the classes in question. Toy with the sample projects. Browse through the online Cocoa web sites. Search the mailing list archives at <http://cocoa.mamasam.com/>. Sooner or later it will pay off, and you'll wonder how you ever got by without Cocoa and Obj-C! :)

j o a r

On Thursday, Mar 20, 2003, at 21:15 Europe/Stockholm, Jason Kenney wrote:

I am trying to figure a way to send simple strings and integers from a PopupMenu to another custom PopupMenu. One is just a popup that sends the title as an int to the other which is a controller the int is needed to determine the contents of the other popupmenu. So far i have only been able to figure out how to get textboxes to display values, but not trading values that are not complete objects. I dont want to overwrite the popupmenu and so far I have found not even something remotley close!!!
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Extermly frustrating Problem: Feel extremly stupid, and the damn tutorials dont care. (From: Jason Kenney <email@hidden>)

  • Prev by Date: NSImage and Photoshop jpegs
  • Next by Date: Re: NSImage and Photoshop jpegs
  • Previous by thread: Extermly frustrating Problem: Feel extremly stupid, and the damn tutorials dont care.
  • Next by thread: Subject: Re: NSString array to -> char**
  • Index(es):
    • Date
    • Thread