I have an NSTableView with 3 columns in Interface Builder. My Applescript code is looping through the keys in the active keychain looking for a match to text that was entered into a textbox also put there by IB.
I want to add a new row each time a match is found in the loop and fill in the name, address, and password of the key that was found in the keychain. I am getting Applescript errors with numbers. Can someone take a look at the code:
-- KeySearch.applescript
-- KeySearch
on end editing theObject -- the text box for the search string
set theSearchKey to string value of text field "TextBox1" of window "Window1"
my findtheKey(theSearchKey)
end end editing
to findtheKey(theSearchKey)
set keysFoundData to make new data source at end of data sources
set tv to table view "TableView1" of scroll view "ScrollView1" of window "Window1"
make new data column at end of data columns of keysFoundData with properties {name:"Name"}
make new data column at end of data columns of keysFoundData with properties {name:"Account"}
make new data column at end of data columns of keysFoundData with properties {name:"Password"}
set theText to theSearchKey
set theFoundKeys to {}
tell application "Keychain Scripting"
launch
tell keychain "login.keychain"
set theKeys to every key
repeat with theKey in theKeys
if name of theKey contains theText then makeARow(theKey, keysFoundData)
end repeat
set data source of tv to keysFoundData
end tell
end tell
end findtheKey
to makeARow(theFoundKey, theDataSource)
set arow to make new data row at end of data rows of theDataSource
set contents of data item "Name" of arow to name of theFoundKey
set contents of data item "Account" of arow to account of theFoundKey
set contents of data item "Password" of arow to password of theFoundKey
end makeARow