Combo box


i am new to xcode and applescriptobjc. I am creating a project where I need to make a combo box and it should have 25 items . I have searched this forum and got lot of answers. However, i am confused. so can anyone help me on how to add items to combo box.

You define a property, called cb in my example, connect it in IB to your combo box, and then just use addItemsWithObjectValues:

property cb : missing value -- IBOutlet connected to the combo box
	on applicationWillFinishLaunching_(aNotification)
		cb's addItemsWithObjectValues_({"First", "second", "Third", "fourth"})
	end applicationWillFinishLaunching_


thank you for your reply Ric

But when I am compiling this code its not showing any item in combo box.

It works fine for me. Try adding the line “log cb” as the first line in the applicationWillFinishLaunching method and let me know what the log says.


thanks again ric,

i have added line “log cb” but it doesnt show anything.

i have created one object and assigned its outlet to combo box. is there anything else i need to do ?

do i need to change anything in inspector panel? . sorry for asking these basic questions, but i am quit new to this platform


It’s hard to know what to say. It should have logged something. Do you have the console window open? Post your code so I can see what you are doing.


pls find script below:

script comboAppDelegate

property parent : class "NSObject"
property cb : missing value
on applicationWillFinishLaunching_(aNotification)
      log cb
      cb's additemWithObjectValues_({"First", "Second", "Third", "Fourth"})
  end applicationWillFinishLaunching_

 	on applicationShouldTerminate_(sender)
	-- Insert code here to do any housekeeping before your application quits 
	return current application's NSTerminateNow
end applicationShouldTerminate_

end script

if you can send me sample script for combo box for reference then it will be great.

The code you have there should work fine – it’s correct. You didn’t answer my question about the console window. Is it open?


i am sorry, i did not answer your question

if you mean console window by terminal window then its not open.

is there any other way to add items?


No, I don’t mean the terminal. Under the run menu in Xcode there’s a choice labeled console. Choose that, and then hit run to run your program, and see what the log says.

yes there are other ways, but they are more complicated. The code you have should work, I’ve tested it. So you must be doing something else wrong.


thanks ric,

any suggestions?

i know i am bothering you but can you send me steps for adding items to combo box, so that i can verify and catch the error.

I don’t understand what you want. I showed you in my first post how to add items to a combo box. It’s very simple, just one line of code. You still did not tell me what the log said. I can’t help you if you won’t respond to my requests.
Open the console window under the Run menu in Xcode, select Console then run your program. Tell me what you see in the log.

Actually you don’t have to create a new object. The outlet must belong to the application delegate object

PS: there is a typo in your script:
It’s addItemsWithObjectValues instead of additemWithObjectValues

hi ric,

i am really very sorry…

please find the log below:

2011-11-07 12:02:46.644 menuitem[1493:707] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
menuitem: OpenScripting.framework - scripting addition “/Library/ScriptingAdditions/Adobe Unit Types.osax” declares no loadable handlers.

Hmm… Is the script you posted above, the whole script? I don’t know why you would be getting errors about Adobe stuff if it is. Did you make the change (adding the missing s) that Stefan posted? That should fix your code. Are you still not getting any items in your combo box?


thanks stefan & ric,

yes i have made the changes, but i am not getting any item in combo box. in inspector panel there is an option to add items to box. however, they are being added by same name that is “Item”. is there any option to change the name of these items. these items are visible.