I am working on a small AS-S app that will allow me to input my time card info. I have a table (w/data source) that has 4 columns (Date, Time In, Time Out, Elapsed Time). The first 3 columns have date/time formatters attached to them. I can add to/remove from the table/data source w/out any problems. However when writing the contents of the data source out to User Defaults, nothing is written.
My first thought what perhaps the data in date-form was causing the problem, so I converted them to strings. No change. The only thing I can figure is the default entries don’t like a list of lists. Is that the case?
to ReadFromDefaults() --> this is called in a "Launched" handler
set theData to the contents of default entry "TimeTable" of user defaults
set theData to ConvertToDates(theData)
return theData
end ReadFromDefaults
to WriteToDefaults() --> this is called in a "will close" handler
set theData to the contents of every data cell of every data row of TimeTableDS
set theData to ConvertToStrings(theData)
set the contents of default entry "TimeTable" of user defaults to theData
end WriteToDefaults
to ConvertToStrings(theData)
repeat with x in theData
set item 1 of x to date string of item 1 of x
set item 2 of x to time string of item 2 of x
set item 3 of x to time string of item 3 of x
end repeat
return theData
end ConvertToStrings
to ConvertToDates(theData)
repeat with x in theData
set item 1 of x to date (item 1 of x)
set item 2 of x to date (item 2 of x)
set item 3 of x to date (item 3 of x)
end repeat
return theData
end ConvertToDates
When running in the debugger, I can see that the data I’m getting from the data source is correct. (TimeTableDS is a property. I’m using Xcode v2.2)
Thanks in advance,
Brad Bumgarner, CTA