Applescript v applescriptOBJ - Pop up button menu item

I’m working on a project using “assistive devices” and have an applescript that works perfectly.

tell application "System Events"
	tell process "theapplication"
		set frontmost to true
		delay 1
		tell tab group 1 of window "theapplicationWindow"
			click pop up button 1
			set theChoice to value of pop up button 1
			set theCount to count menu items of menu of pop up button 1
			set listofItems to name of every menu item of menu of pop up button 1
			key code 53
		end tell
	end tell
end tell

When I run this in script editor I get the value, the count and the list as I expect, but when I put this into an applescriptOBJC project in X code -I can get the current value - but I get 0 for theCount and an empty listofItems.

Any suggestions?? I’ve looked at “current application’s NSPopUpButton” but I guess I can’t figure out how to make that work.


I think I found my solution!

Post a message here saying something doesn’t work. Then re-copy and paste your code into Xcode.

I spent hours on this, and now it seems to be working!!! I have no idea why or what I did wrong before.