tags:

views:

39

answers:

1

Is there any way (programmatically) that i can find the location of "Resource" folder. I want to create a new file in it at run time.

+3  A: 

To get path to resource folder use:

NSString *path = [[NSBundle mainBundle] resourcePath];

However you won't be able to write anything there in run-time. New files should be saved to 1 of the following directories (depending of their usage):

  1. Documents directory - persists between app launches and backuped by iTunes

    NSString* docPath = [NSSearchPathForDirectoriesInDomains
                   (NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    
  2. Cashes directory - persists between app launches but not backuped by iTunes - you should place there files that can be easily restored by your program to improve device backup time

    NSString* cachesPath = [NSSearchPathForDirectoriesInDomains
                   (NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    
  3. Temporary directory - may not persist between app launches

    NSString* tempPath = NSTemporaryDirectory();
    
Vladimir
Thank you Vladimir.
Abhinav