Reputation: 38172
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.
Upvotes: 4
Views: 3646
Reputation: 170859
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):
Documents directory - persists between app launches and backuped by iTunes
NSString* docPath = [NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
Caches 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];
Temporary directory - may not persist between app launches
NSString* tempPath = NSTemporaryDirectory();
Upvotes: 7