How do I clear my temp directory in the simulator?
I've started caching graphics that my app downloads off the net to my app's temp directory using NSTemporaryDirectory().
I need to be able to scrub my temp directory clean to test initialization.
However, nothing I do clears out the temp directory. I can delete my app from the simulator's springboard; I can use the "reset content and settings" command, I can stand on my head, but the files in temp remain. What's going on here?
Also, when I go and look in ~Library/Application Support/iPhone Simulator/User/Applications, I can see my app's directory, including it's temp directory. However, the tmp directory appears empty. What's up with that? Are the files tagged as invisible?
I don't remember how to specify paths that include spaces in terminal, so I can't look in tmp there.
I can also escape spaces and other single special characters with a backslash, so your example would be
cd Desktop/My\ Folder/images
Another REALLY cool trick is that you can type a command, then drag a file or folder onto the command line in terminal. The terminal app will put the path to that file folder right in-line. Very helpful.
Last edited by Duncan C; 01-11-2009 at 11:44 AM.
Reason: typo
I found my app's tmp directory on the simulator. To find it, I used to locate command. To use locate, I first had to build a locate database for my Mac. To do THAT, I issued the following command in the terminal:
sudo /usr/libexec/locate.updatedb
Be aware that that command builds a locate database that any user on your Mac can use to see any file, even files that are normally not accessible to other users.
Once you've done that, you can use the locate command to locate a file that you know should be in your tmp directory. My app created a file I new should be there, so I used that filename.
The "f7MhxBVPFt4q1lU9r0pfjU+++TI" part of that path is, I think, an encoded version of the UUID (unique ID) for the application.
Does anybody know if I would cause any problems in the simulator if I used the terminal to delete all the files in that temp directory? There are a few files that I did not create, like: xcodeDocAccess.
I have some code that deletes everything in the app temp folder. It causes problems if I run it on the simulator. On the sim the temp folder is shared among other apps and deleting some Xcode files that are in there did cause some problems with Xcode, although not extremely bad problems.
I run the temp folder deleting code only on the device. I don't delete the folder itself, only the contents.
What you could do is make sure to add a folder inside the temp folder with a unique name and only put your temp files inside that. Then delete this folder only when you need to.
On a similar note, how do I clear the temp directory on the device?
I have a UIwebView leak. The only way to stop the crashing seems to be to reboot the iPhone.
I don't understand the difference that happens when the iPhone is rebooted vs. have the program quit.
Is there a way to clear ALL the cache? I've tried setting
[[NSURLCache sharedURLCache] setMemoryCapacity: 0];
[[NSURLCache sharedURLCache] setDiskCapacity:0];
and
NSURLCache *sharedCache = [NSURLCache sharedURLCache];
[sharedCache removeAllCachedResponses];