Hello,
after a while I opened my app again and got same errors now. There are obviously read und write errors. Maybe it’s an old topic meanwhile, but be patient with me.
property NSMutableArray : class "NSMutableArray"
property userLocationSchuelerDaten : (path to "asup" from user domain) & "SchuelerListenDaten" as text
” reading:
set myPath to POSIX path of ((userLocationSchuelerDaten as string) & ":" & (selectedContent as string))
display alert (myPath) ” - OK
set myDataSource to NSMutableArray's alloc()'s initWithContentsOfFile: myPath
display alert (myDataSource)”> "msng"
on error number: -1708 ("doesn't understand message")
” writing:
set FILE_PATH to POSIX path of ((userLocationSchuelerDaten as string) & ":" & (kursname as string))
if not ((nDataSource's writeToFile:FILE_PATH atomically:1) as boolean) then
error
set deskPath to POSIX path of (path to desktop)
set deskPath to current application's NSString's stringWithString:deskPath
set FILE_PATH to deskPath's stringByAppendingPathComponent:"Test file"
set nDataSource to current application's NSMutableArray's arrayWithArray:{1, 2, 3, 4, 5}
set theResult to (nDataSource's writeToFile:FILE_PATH atomically:true) as boolean
if not theResult then
display dialog "Saving failed"
error number -128
end if
set myDataSource to (NSArray's arrayWithContentsOfFile:FILE_PATH)'s mutableCopy()
set theList to myDataSource's componentsJoinedByString:", "
display dialog (theList as text)
Is one the objects in the array maybe an non property list object (or create subclasses of it)? What is the structure of the plist file? Does it start with the code below?
No it has the form of an array containing dictionaries. When I store the following contents in a file named “test.plist” on my desktop:
I can succesfuly use the following code:
use framework "Foundation"
use scripting additions
set theFile to POSIX path of ((path to desktop as string) & "test.plist")
set nDataSource to current application's NSArray's alloc()'s initWithContentsOfFile:theFile
return nDataSource as list
The code will return as expected:
Can you confirm that this is the same on your machine?
To make a notice beforehand: my app worked up to now.
But now I can read and write the file from and to everywhere but not to (my)Library/Application Support/“myFile” .
The name of “myFile” is readable but the contents of it is not loadable.
What happened meanwhile?
property userLocationSchuelerDaten : (path to "asup" from user domain) & "SchuelerListenDaten" as text
set myPath to POSIX path of ((userLocationSchuelerDaten as text) & ":" & (selectedContent as text))
” - selectedContent: user selected a file in a tab. view
display alert (myPath as text) ”>
/Festplatte/Users/heinrichhoffmann/Library/Application Support/SchuelerListenDaten/Testliste kurz ”> correct
( /Harddisk/Users/myComputer/Library/App..Sup/myFolder/myFile)
set helpDataSource to NSMutableArray's alloc()'s initWithContentsOfFile:myPath
set anzahl to helpDataSource's |count|()
display alert (anzahl) ”> correct
set a to (helpDataSource's valueForKey:"derName") as list ”(see the pList above)
display alert ("a") ”> error -1708
display alert (a) ”> error -1700
Meanwhile I noticed that Apple has published a new Xcode version (Xcode 8) without an automatic update. My OS system is OS 10.12 now.
The maximum of project target of my Xcode version is to set for 10.11.
Does that be the reason for my troubles now?
I don’t get any more debug informations in the pane below, so not
current application’s NSLog(“helpDataSource = %@”, helpDataSource).
Compiling the file in the project setting view I get in the debugging view pane by clicking the ˜Debug View Hierarchy’ button the following message:
warning: could not load any Objective-C class information from the dyld shared cache. This will significantly reduce the quality of type information available.
(lldb)