This code is copied and modified from a working handler, but it fails on the line set theList to.
For the life of me I can't work out why. The variable stringToFind2 is an iTunes playlist persistent ID, and display as an alphanumeric string.
I've checked and double checked all the bindings and Model Key Paths.
Any advice appreciated, please.
on addOnAChosenAdvertisement_()
try
tell advertisementsThatAreChosenTable to deselectAll_(me)
tell AdvertisementsToChoosefromArrayController
set allTheItems to selectedObjects()
end tell
repeat with theItems in allTheItems
set stringToFind1 to theItems's advertisementsName as text # advertisementsName, advertisementsTrackPath
set stringToFind2 to theItems's advertisementsTrackPath as text
display dialog stringToFind2 as text
tell AdvertisementsThatAreChosenArrayController
set aPredicate to current application's NSPredicate's predicateWithFormat_("advertisementsTrackPath == %@", stringToFind2)
say 1
set theList to advertisementsThatAreChosenData's filteredArrayUsingPredicate_(aPredicate)
if theList's |count|() = 0 then
say 3
my advertisementsThatAreChosenData's addObject_({advertisementsName:stringToFind1 as text, advertisementsTrackPath:stringToFind2 as text})
set my disableTheRemoveAdvertisementButton to false
end if
end tell
set my advertisementsThatAreChosenData to my advertisementsThatAreChosenData
end repeat
tell advertismentsToChooseFromTable to deselectAll_(me)
tell advertisementsThatAreChosenTable to deselectAll_(me)
my setTheAdvertisementsMoveArrows()
on error errmsg number errnum
display dialog "selectNewAdvertisement_ " & errmsg & return & errnum & return & return & "p = " & p
end try
my setTheAdvertisementsMoveArrows()
my interimSaveData()
end addOnAChosenAdvertisement_