Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

pinsrw

macrumors regular
Original poster
May 30, 2010
194
0
My iPad app needs to store its data in some files.
On the simulator, my program can read and write its data files just fine.
It stores its data, then I tell it to exit and later when I run the app, it reads that
data in just fine. I just tried running the app on an iPad however and
it appears that file writing is not happening. Is there some sort of
limitation that's imposed on ad hoc apps during testing that doesn't
appear in real apps? My app has already been accepted and is being sold
so I assume it's just my iPad that has got this problem. Note, I did not
update iOS before running the app on the iPad.
Thanks.
 

(marc)

macrumors 6502a
Sep 15, 2010
724
2
the woods
You can do things in the Simulator that you can't on the device. Permissions differ from the Simulator to the device. You can use NSFileManager to find out what the error is and then post back here.
 

pinsrw

macrumors regular
Original poster
May 30, 2010
194
0
You can do things in the Simulator that you can't on the device. Permissions differ from the Simulator to the device. You can use NSFileManager to find out what the error is and then post back here.

I fixed it. I was creating a file in $HOME. Turns out $HOME is not writable but $HOME/Documents is. Now, if I only knew why $HOME doesn't point into /Users...
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
I fixed it. I was creating a file in $HOME. Turns out $HOME is not writable but $HOME/Documents is. Now, if I only knew why $HOME doesn't point into /Users...
You shouldn't be using $HOME on the device. You should be retrieving the Documents folder via NSSearchPathForDirectoriesInDomains(NSDocumentDirectory...

As for /Users, there's no such thing on a device.
 

ulbador

macrumors 68000
Feb 11, 2010
1,554
0
Does $HOME actually even resolve to anything in code?

That is a special environment variable that gets set when you log in via something like bash or csh, and wouldn't actually exist anywhere else but on a unix-like terminal..

I'm guessing it probably wasn't resolving to anything and you were just opening /Documents... who knows though
 

pinsrw

macrumors regular
Original poster
May 30, 2010
194
0
Does $HOME actually even resolve to anything in code?

Oh yes, definitely... on the iPad.
Calling getenv("HOME") gives the path to the Applications directory for the app.
I'd guess one ought not rely on it though.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.