Page 1 of 1
Storing data locally
Posted: Mon Dec 12, 2011 7:49 pm
by Tomjr
Hello all,
How would I go about storing data locally onto an iOS device so that it is always there even when someone closes and reopens the app?
Thanks

Re: Storing data locally
Posted: Mon Dec 12, 2011 10:37 pm
by Jellicle
Save it into the app's Documents folder. Here's some code showing how to write a text file to that folder:
Code: Select all
on writeTextFile fileTowrite,dataTowrite
set the defaultFolder to specialFolderPath("Documents")
put dataTowrite into URL (("file:"&fileTowrite&".txt"))
end writeTextFile
You pass the file name and data to the command. So
Code: Select all
writeTextFile "preferences","1,0,3,4,5"
would write "1,0,3,4,5" to a file named preferences.txt into the Documents folder.
Gerry
Re: Storing data locally
Posted: Mon Dec 12, 2011 10:44 pm
by Tomjr
Thanks! And how would I read that data?
Re: Storing data locally
Posted: Mon Dec 12, 2011 11:26 pm
by Jellicle
Tomjr wrote:Thanks! And how would I read that data?
Code: Select all
function readFromFile whatFile
set the defaultFolder to specialFolderPath("Documents")
return URL (("file:"&whatFile&".txt"))
end readFromFile
So you can do:
Code: Select all
put readFromFile("preferences") into field "PreferencesField"
Gerry
Re: Storing data locally
Posted: Tue Dec 13, 2011 12:24 am
by Tomjr
Thank you very much!

Re: Storing data locally
Posted: Fri Dec 30, 2011 6:38 pm
by FireWorx
Hi, I was checking the ability to update my PDF maps via iTunes by dropping the updates into the appropriate folder located in the documents folder. I have several folders with say 50 PDF's each in them.
All is good BUT.... I noticed that my Preferences folder which contains a text file that I write to and write from is also open for viewing and editing. This is not a good thing because for one thing I use the prefs file to do some time calculations that allow the users to try the program for 6 weeks. Altering this file and re inserting it could give the user an unlimited free trial.
SO... The question is. Are there other IOS folders that allow the contents to be changed via script but are not subject to file sharing if it is turned on in the standalone settings? Or are there settings that can be employed on certain folders within the documents folder that lock them or that can make files or folders invisible or locked?
What might be the best method to have several folders that can be edited and shared as well as having others that can be edited but are not shared?
Dave
Re: Storing data locally
Posted: Fri Dec 30, 2011 7:16 pm
by gpb01
FireWorx wrote:
...
SO... The question is. Are there other IOS folders that allow the contents to be changed via script but are not subject to file sharing if it is turned on in the standalone settings?
...
Use the "
Library" folder ... he is backuped but is not accessible via iTunes Document Sharing
Guglielmo
Re: Storing data locally
Posted: Fri Dec 30, 2011 8:07 pm
by FireWorx
Thanks I will givie that a try !