Monday, March 1, 2021

#1 2021-01-08 12:37:03 pm

wsup55
Member
Registered: 2018-12-21
Posts: 5

updating drop down options from plist record

Hello. I'm a non-developer type that has been hacking together applescripts for user automation for the past handful of years. I'm at the point that I'm looking to expand the capability of my user prompts/interactions. That is to say, I'm very new to AppleScriptObjC and Xcode. I'm getting stuck on what I assume is an easy hurdle however my Google-fu hasn't netted me a working result thus far.

I have an Applescript App project started in Xcode. I have a plist file where I save info relating to previous times the script has been run. I'm trying to read that plist and then load the listed info as choice options in a drop down. I've stripped the script down to the parts below in question. It is historyList that I'm trying to update into the dropdown options but it only loads what is initially set when the property is made which is currently at "missing value". I can successfully read the plist and return my list items in an alert dialog but not update into the drop down. I have a feeling it's a proper connection setting in the xib that I'm missing but I'm feeling a bit lost. Can anyone point me in the right direction?


Applescript:


script AppDelegate
   property parent : class "NSObject"
property historyList: missing value

   -- IBOutlets
   property theWindow : missing value

   on applicationWillFinishLaunching_(aNotification)
       -- Insert code here to initialize your application before any files are opened
set plistFile to "/Users/myuser/Library/Preferences/opener.plist"
set thePlist to (current application's NSDictionary's dictionaryWithContentsOfFile:plistFile) as record
set historyList to thePlist's campaign as list
   end applicationWillFinishLaunching_

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

on appSearch_(sender)
-- do stuff when search button is pressed. sorting out drop down before continuing here
end appSearch_

end script

Offline

 

#2 2021-01-15 11:06:11 pm

technomorph
Member
Registered: 2017-12-14
Posts: 178

Re: updating drop down options from plist record

Create an outlet to your menu

Use addMenuItemWithTitle:

You may also want to clear any previous menu items.

https://developer.apple.com/documentati … guage=objc

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)