How to keep the application directory of the iphone simulator the same when you run it each time

advertisements

i met a problem with iphone simulator application directory, when i run the application everytime, the name of application directory was changed each of time,can anyone tell me how to keep a static application directory ?


i'm going to take a guess here and say..

you don't need a static directory.

I think what you need is to get the 'base directory' programatically.

NSString *docsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *path = [docsDirectory stringByAppendingPathComponent:@"fileName.txt"];

you should be saving your user files there (or somewhere similar)

or alternatively something like

NSBundle* bundle = [NSBundle mainBundle];
NSString* path = [bundle executablePath]
//or
NSString* path = [bundle resourcePath];

and then append your own paths onto that.

hope that helps.

NEW INFO:

If you are saving information, (a log, stats etc..) you can retrieve the files saved in the NSDocumentDirectory above using the Xcode organiser.

  • select your device
  • got the summary tab
  • find you application in 'Applications' section.
  • expand the entry and it should have an 'Applcation data' entry.
  • press the down arrow on the right to save your files.