Reading and Writing CSV Files and their persistence ...

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Reading and Writing CSV Files and their persistence ...

Post by LC4iOS » Sun Dec 08, 2013 7:23 am

14301-how-do-i-read-write-to-files-in-ios

Love the lessons.
Makes everything look so easy.

I'm about to try the lesson above in conjunction with installing a csv file to load buttons with text.
Say 6 buttons on a card.
Read in the csv values from the text file I installed with the app.
Then based up on the selection,
Load six more button text for that specific selection and display the same card with new text etc.

I would also like to save some data from user input and what screen they were on etc.

I'd like to save this data and have the saved data persist even after I update my app or install the app again etc.
Is it possible to do this in iOS?

I'll keep researching until I find it or someone points me in the right direction.
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: Reading and Writing CSV Files and their persistence ...

Post by LC4iOS » Sun Dec 08, 2013 7:36 am

...
If they are only temporary files that are used during the execution of the application, then use the "temporary" path.
If the files are to remain accessible for each launch of the application, then use the "documents" path. This is where application specific information is stored that is also backed up by iTunes.
...
you can create folders within the documents folder. Have a look at the dictionary entry for: "create folder"
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Reading and Writing CSV Files and their persistence ...

Post by Simon » Sun Dec 08, 2013 7:47 am

Hi LC4iOS,
I'd like to save this data and have the saved data persist even after I update my app or install the app again etc.
Update Yes, Install No. That is an install after deleting the app. Once the app is deleted the documents folder is also deleted.
The rest you can do.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: Reading and Writing CSV Files and their persistence ...

Post by LC4iOS » Sun Dec 08, 2013 8:27 am

OK, so even on my own iPhone 5 that I own, I can't have a folder with a database on it that maybe multiple apps that come and go can access?



Just a follow up question.

If I just add another button to the Hello World app, build it, then install on my iOS device using Keychain Access by dragging an dropping on Applications under my device, its this considered an update or a new install.

Already found.
...
In the iOS Standalone Application Settings you can set the Internal App ID, by default this is com.yourcompany.yourapp.

This is what iOS uses to identify the app, if there is an app on the device with the same identifier as the app you are adding it will assume it is an update and overwrite the app on the device. You just need to make this ID different for each of your apps.
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Reading and Writing CSV Files and their persistence ...

Post by Simon » Sun Dec 08, 2013 8:52 am

I can't have a folder with a database on it that maybe multiple apps that come and go can access?
Not with Apples sandboxing. Now I have recently seen a shell method but that was OSx.
I think the idea is if you need it, then use iCloud or other online service.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: Reading and Writing CSV Files and their persistence ...

Post by LC4iOS » Sun Dec 08, 2013 9:46 am

Ah, yes of course.
A Client/Server solution.

Just a shame to waste all the room on 64gig iPhone 5.

Thanks for the replies.
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Reading and Writing CSV Files and their persistence ...

Post by Simon » Sun Dec 08, 2013 9:58 am

Just to be clear.
You can create your data file of any size (< what is available), you just cannot have multiple apps using that same data.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: Reading and Writing CSV Files and their persistence ...

Post by LC4iOS » Sun Dec 08, 2013 8:54 pm

Understood.
Many Thanks.
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10044
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Reading and Writing CSV Files and their persistence ...

Post by FourthWorld » Sun Dec 08, 2013 10:44 pm

Search Google fire"CSV must die". :)

Unless you need to support CSV because some other program you're working with offers no alternative, there are many better formats worth considering, even the humble yet efficient LiveCode stack file.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: Reading and Writing CSV Files and their persistence ...

Post by LC4iOS » Mon Dec 09, 2013 5:57 am

Hi Richard,

Thanks for NOT suggesting XML.
I was just trying to keep it simple and easy to read n write etc.

But it looks like LiveCode lessons and samples makes it easy to do all.
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10044
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Reading and Writing CSV Files and their persistence ...

Post by FourthWorld » Mon Dec 09, 2013 6:27 am

LC4iOS wrote:Thanks for NOT suggesting XML.
If you ever see me recommending XML for any system where it's not absolutely required, that'll be your clue that the pod people have replaced me, and you can safely ignore anything that imposter writes. ;)
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

LC4iOS
Posts: 88
Joined: Tue Dec 03, 2013 8:15 pm

Re: Reading and Writing CSV Files and their persistence ...

Post by LC4iOS » Fri Dec 20, 2013 10:38 pm

LOL. Will do.

I've moved on to LiveCode SQLite samples.
If You can read and copy n paste its embarrassing how easy it is.

I've caught myself a number of times trying to do it my way.
Finding out its much easier to follow the samples and do it the LiveCode way.
Thanks to RunRev.
Thanks to LiveCode forum members.

LiveCode v5.5.5 - iOS Android Mac Windows - 6.5 Community
27" 2012 iMac i5, MacBook Pro, MacBook Air, iPhone 5, iPhone 4
xCode 5.0.2 - iOS7 - OS X Mavericks
Paid Apple iOS Developer Program Member

Post Reply