Saving data in iPhone app (revMobile)

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ukaussie
Posts: 23
Joined: Mon Sep 28, 2009 9:04 pm

Saving data in iPhone app (revMobile)

Post by ukaussie » Fri Apr 02, 2010 10:56 pm

How might i go about saving data before the app quits? and then loading the data again the next time the app opens?

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Saving data in iPhone app (revMobile)

Post by Klaus » Sat Apr 03, 2010 11:12 am

Hi ukaussie,

check the PDF that came with the latest alpha (6 or 7?) for the different "specialfolderpath()" codes supported on the iPhone.


Best

Klaus

ukaussie
Posts: 23
Joined: Mon Sep 28, 2009 9:04 pm

Re: Saving data in iPhone app (revMobile)

Post by ukaussie » Sat Apr 03, 2010 2:36 pm

Hi Klaus,

I've read the PDF but it is not clear how to transform that information into actual code. I've tried setting the code to the below (for saving and retrieving, respectively), but it doesn't work.

Code: Select all

put tResultsField into URL "file:/home/documents/saveddata.txt"

Code: Select all

put URL "file:/home/documents/daveddata.txt" into field "resultsField"
Do i have the path correct? They recommend saving data to the 'documents' folder within the iPhone app bundle. If i have the path correct do i have the syntax incorrect?

Grant.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Saving data in iPhone app (revMobile)

Post by Klaus » Sat Apr 03, 2010 2:54 pm

Hi Grant,

use the "specialfolderpath()" function!

...
## I would recommend to create a folder for your app in that folder first.
## This way ther is no danger that a file named "saveddata.txt" already exists!
put tResultsField into URL("file:" & specialfolderpath("documents") & "/saveddata.txt")
...

Best

Klaus

ukaussie
Posts: 23
Joined: Mon Sep 28, 2009 9:04 pm

Re: Saving data in iPhone app (revMobile)

Post by ukaussie » Sat Apr 03, 2010 5:44 pm

Hi Klaus,

That worked! Brilliant, thanks for your help.

Cheers,

Grant.

fmuller
Posts: 11
Joined: Mon Mar 08, 2010 1:02 pm

Re: Saving data in iPhone app (revMobile)

Post by fmuller » Sat Apr 10, 2010 9:01 pm

Hello,

I wrote these 2 functions below for my application :
And interesting link for folders : http://intkeystrokes.posterous.com/wher ... obile-runr

Code: Select all

global gConfigArray

function fSaveConfigFile
   --Save Configuration File
   put specialFolderPath (documents) & "/Config.txt" into lConfigFile
   open file lConfigFile for write
   repeat with tVarNum = 1 to 11
      write gConfigArray[tVarNum] & CR to file lConfigFile 
   end repeat
   close file lConfigFile
end fSaveConfigFile

function fReadConfigFile
   --Read Configuration File
   put specialFolderPath (documents) & "/Config.txt" into lConfigFile
   open file lConfigFile for read
   repeat with tVarNum = 1 to 11
      read from file lConfigFile for 1 line
      put it into gConfigArray[tVarNum]
   end repeat
   close file lConfigFile
end fReadConfigFile
I hope this help, Cheers, Fabrice

Post Reply