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

TiberiusXavier

macrumors member
Original poster
Apr 18, 2010
54
0
Chicago
I am writing an application where I save a favorites list as a .plist file. Without specifying the path, I would think the file is using the application's private Documents area. When I run my app on the simulator (version 3.1.3), the favorites work as expected. However, I load the image on my actual iPhone 3GS, the favorites appear to work, but when I relaunch my app, it seems like the list is missing. Upon adding some logging to debug the problem, the writeToFile operation (not shown in the code below) returns FALSE/NO. Is there a better way to explicitly define the full path to the .plist file?

SOLVED
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Without specifying the path, I would think the file is using the application's private Documents area.

Where does the documentation state that this magically guessing that you want to save in your Documents folder happens? (hint it doesn't say this as that doesn't happen).

Use the documented function to get the path to your documents folder and the NSString path utilities to append the filename.
 

TiberiusXavier

macrumors member
Original poster
Apr 18, 2010
54
0
Chicago
Where does the documentation state that this magically guessing that you want to save in your Documents folder happens? (hint it doesn't say this as that doesn't happen).
Thanks for your flippant reply. I really need that this morning. Of course there is no such thing as undocumented functionality.

After all, just because every Mac, PC, Linux box, Sun station, even OpenVMS have a concept of a current working directory. What was I thinking?

I decided to use the NSUserDefaults instead. Works fine. Thanks anyway.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
As you are starting to learn, I hope, iPhone OS is not like any of these.

Whilst this is true the iPhone OS does have a cwd. It's just not silently set to the documents directory for the currently running app. And if it was this would be documented.
 

TiberiusXavier

macrumors member
Original poster
Apr 18, 2010
54
0
Chicago
As you are starting to learn, I hope, iPhone OS is not like any of these.

Indeed. I knew that the simulator may not behave identically to the device. I just didn't anticipate file and directory differences, and I took for granted that the startup path is someplace other than the applications sandbox.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.