Hi,
in a table view the user sets decimal numbers into some column cells of a selected row. After edditing every cell the sum of the numbers should set into the cell in the last column. That have I done i AS Studio, but in ASObjC I need help.
As a solution being for the time I have bind the following code to a button. That helps only partly.
property parent : class "NSObject"
property theData : missing value
property theArrayController : missing value -- contentArray ArrayController
-- IB Actions (button clicks)
on insertNames_(sender)
try
set theContents to the clipboard as string
end try
set oldTextItemDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set theCount to (count text items of theContents)
if last text item of theContents is "" then
set theCount to theCount - 1
end if
set newData to {}
repeat with i from 1 to theCount
set newName to text item i of theContents
set newData to newData & {{column1:newName}} -- arrangedObjects TableColumn and identifier
end repeat
set my theData to newData
set AppleScript's text item delimiters to oldTextItemDelimiters
end insertNames_
on calculate_(sender)
set theArraysSelectedRow to theArrayController's selectedObjects()
set sum to 0
repeat with a in {"column2", "column3", "column4"} -- arrangedObjects TableColumn and identifier
set cellContent to (theArraysSelectedRow's valueForKey_(a))
try
set sum to sum + (cellContent as integer)
end try
end repeat
--log sum
theArraysSelectedRow's setValue_forKey_(sum, "column5")
end calculate_
Heiner
Model: iMac
Browser: Safari 525.13
Operating System: Mac OS X (10.6)