Loading Resources

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
observ3
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 34
Joined: Mon Oct 11, 2010 11:05 pm

Loading Resources

Post by observ3 » Sun Jan 23, 2011 5:52 am

My app will require loading text and image files from a resource folder. This is all working wonderfully on the desktop, but when I try to do it in iOS the files don't load...

So far I've tried accessing specialFolderPath("home") "documents", and even "library" and none are showing the files I selected for inclusion in the Standalone Application settings screen. I've already triple checked my capitalization and spelling... I just can't seem to see the files.

I'm I totally missing where the included files are being stored?
Check out my LiveCode program, WriteSpire, on the App Store!

ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Contact:

Re: Loading Resources

Post by ctflatt » Sun Jan 23, 2011 12:17 pm

observ3:

Try this.

You would first create a folder for the images and text, and place the resources inside. Create this folder in the same directory as your stack to maintain the relative path names of your files.

In your stack, insert a New Referenced Control, browsing to the folder you created, making sure the path is relative to the stack.

In the Standalone Settings, set the Copy Files option to copy the folder you created.

I have attached a demo stack.

Test in Simulator for iPhone 4.2, or create the mobile standalone for iPhone 4.2 to test on device.

Hope this helps.

This can also be done programmatically, but unless you specifically need to, why bother?

In your own standalone build, did you right-click the mobile app, and choose "Show Package Contents"? I found this helpful when trying what you're attempting.

In this example, you should see an images folder at the same level as the engine.

:Todd
Attachments
referenced_images.zip
Demo showing referenced control for images for iOS.
(33.97 KiB) Downloaded 312 times

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

Re: Loading Resources

Post by Klaus » Sun Jan 23, 2011 1:20 pm

Hi observ3,

the "included" files can be found here on iOS:
specialfolderpath("engine")


Best

Klaus

observ3
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 34
Joined: Mon Oct 11, 2010 11:05 pm

Re: Loading Resources

Post by observ3 » Sun Jan 23, 2011 2:36 pm

Will take a look at your stack.
Thanks!

And yes, I've browsed contents before, but was confused since I named my folders "Documents" and "Library"... so I figured that specialFolderPath("Documents"), etc. would find them.

If I'm reading the documentation from RunRev and Apple right, everything we do must be within the Library and Document folders, right? I thought both warned against creating any folders in the "home" directory other than Documents, Library, and Cache.
Check out my LiveCode program, WriteSpire, on the App Store!

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

Re: Loading Resources

Post by Klaus » Sun Jan 23, 2011 3:34 pm

Hi observ3,

please do NOT name the folders you want to "include" "Documants" and/or "Library",
which may confuse the standalone process!

And just to prevent misunderstandings:
1. specialfolderpath("Documents") will point to the already present OS folder inside of the current users HOME folder.

2. ...everything we do must be within the Library and Document folders
Everything we need to STORE during runtime should go there!

3. ...I thought both warned against creating any folders in the "home" directory other than Documents, Library, and Cache.
These folders are already present in the current users HOME directory (except "Cache") and thus cannot be created by your app!


Best

Klaus

observ3
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 34
Joined: Mon Oct 11, 2010 11:05 pm

Re: Loading Resources

Post by observ3 » Sun Jan 23, 2011 4:53 pm

Thank you so much for clearing this up!
Check out my LiveCode program, WriteSpire, on the App Store!

ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Contact:

Re: Loading Resources

Post by ctflatt » Tue Jan 25, 2011 11:10 am

observ3:

Glad you're on your way. BTW, I copied this from the iOS Release Notes documentation:
Each application in iPhoneOS is stored in its own 'sandbox' folder (referred to as
the home folder. An application is free to read and write files within this folder and its descendants,
but is not allowed to access anything outside of this.
Klaus points out that anything you need to STORE (and eventually backup—new files, preferences, etc.) should be saved to the "documents" folder... folder names are case sensitive.

Good luck, and keep us informed of your progress!

:Todd

Post Reply