iOS write to file issue
Sergio Schvarstein
sschvarstein at gmail.com
Mon Dec 2 11:24:23 EST 2013
Hi,
I am trying to write a simple text file in iOS. It works OK in iOS simulator but it doesn’t work on a device.
The file contains only a number, which is the number of the card I want to go while opening the stack. My intention is to simulate multitasking for opening the last card viewed in the previous session while reopening the app.
Here are my scripts:
1. First I open the file at preOpenStack for reading its value.
local myFile, myVariable
on preOpenStack
put specialFolderPath("home") & “/“ into myFolder
put “myfile.txt” into myFilename
put myFolder & myFilename into myFile
open file myFile
read from file myFile for 1 — the file contains only a number
put it into myVariable — here I save the card number where to jump
close file myFile
end preOpenStack
This works OK and I jump to the card later, after some inits.
…
go card myVariable
...
2. Then, I move to different cards and I store the card number in myVariable. While closing the app:
on shutdown
open file myFile for write
write myVariable to file myFile — this is supposed to replace the contents of the file with the new card number, which is stored in myVariable
close file myFile
end shutdown
This script doesn’t works on the device, because when I reopen the app it always jumps to card 1.
In iOS Simulator it works ok and jumps to the last card viewed while reopening.
What am I doing wrong ?
Thanks in advance.
______________________________
Sergio Schvarstein
sschvarstein at gmail.com
______________________________
More information about the use-livecode
mailing list