I am trying to retrieve values from a .plist to transfer to a .csv
The values will be different with each use, the script I have is
set f to (path to desktop as text) & "results.plist"
tell application "System Events"
tell (value of (contents of property list file f)) as list
set |track name| to {}
end tell
end tell
return |track name|
from your thread in the AppleScriptObjC section I assume you need the code for an ASOC project,
this is a “native” solution, the first line contains the keys, then the values all comma separated
set filePath to POSIX path of (path to desktop) & "test.csv" -- sample path, change it something appropriate
set theArray to arrayController's arrangedObjects() -- arrayController is a property connected to an NSArrayController instance
set csvList to current application's NSMutableArray's array()
csvList's addObject:((theArray's objectAtIndex:0)'s allKeys()'s componentsJoinedByString:",")
repeat with anItem in theArray
(csvList's addObject:((anItem's allValues())'s componentsJoinedByString:","))
end repeat
set csvText to (csvList's componentsJoinedByString:return)
csvText's writeToFile:filePath atomically:true encoding:(current application's NSUTF8StringEncoding) |error|:(missing value)
what is the code for importing back in to the table view? if it makes it easier I could have a save as sender and save as a .plist
on ChooseSave:sender
set resultFile to (choose file name with prompt "Choose Save Location" default name "SMPTE Save" default location path to desktop) as text
set filePath to POSIX path of resultFile & ".plist"
set theArray to ArrayController's arrangedObjects()
theArray's writeToFile:filePath atomically:true
end ChooseSave: