Unexpected behavior in iOS app
Terry Vogelaar
tvogelaar at de-mare.nl
Wed May 11 02:17:21 EDT 2011
I'm running into a few problems building an iOS app.
The most important one is this one. I want it to retrieve data from an 18MB text file, because I want it to work when the device is not connected to the internet. So I tried this:
on preopenstack
put "file:" & specialFolderPath("documents") & "/Muziek.txt" into docsmap
if the environment = "mobile" then
answer "Download or use local?" with "Download" or "Local"
if it is "Download" then
put url "http://dl.dropbox.com/u/10128030/Muziek.txt" into muzieklijst -- not the actual url
put muzieklijst into url docsmap
else
put url docsmap into muzieklijst
end if
else
put url "file:~/Dropbox/Public/Muziek.txt" into muzieklijst
end if
-- and some additional processing of the muzieklijst data that works fine
end preopenstack
As you can see, it intends to write the text file I expected the download to be only the first time the app is used, or optionally when I know the file has changed. It takes a few minutes staring at a black screen, but eventually it works.
But apparently it doesn't save the file on the iPod Touch. The variable muzieklijst only contains data when it is freshly downloaded. If I tap on the "Local" button, muzieklijst stays empty.
In this case, to drag the file to the Documents area of the app in the Apps tab when the iPod is connected to iTunes is even better than downloading. So I tried it, and it is there each time I connect my iPod to iTunes. But the app apparently can't access it when I choose "Local".
I also tried to run it using the iPhone Simulator. But apparently the downloaded file is saved to ~/Documents/Muziek.txt, while I expect it to end up in ~/Library/Application Support/iPhone Simulator/4.1/Applications/CCDE447A-9119-43DF-B1C3-33A59507200B/Documents/Muziek.txt
So apparently specialFolderPath("documents") doesn't work as expected on iOS.
That was the main problem; but I encountered some minor ones as well.
For example, pickers. I see a beautiful picker on iOS when using a button with the menuMode set to 'option'. But on screen, the button looks 90'ish with an ugly border around it. So I tried to set the menuMode to 'pulldown' or any of the other menuMode settings, to have more control over how the button looks on screen. But then I loose the picker control; instead I have an ugly 90'ish list to choose my items from.
Also, I applied a great technique I learned on the Beginners Mobile Course on the Simulcast. I put a bunch of PNGs in a Resouces substack and I copied the scripts from the Ticked Off stack, used in the demo. It worked great; it scaled all the icons on the main stack. But as soon as I switched an icon (using: "set the icon of me to 1023"), it showed (the center portion of) the large version of that icon; not the downscaled one I wanted to see.
Terry
More information about the use-livecode
mailing list