Finding a path to a resource folder?

Is there any way (programmatically) that I can find in the Resource folder. I want to create a new file in it at runtime.

+4
source share
1 answer

To get the path to the resource folder, use:

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

However, you cannot write anything at runtime. New files must be saved in 1 of the following directories (depending on their use):

  • Document Directory - Saved Between Launching Applications and iTunes Backup

     NSString* docPath = [NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; 
  • Caches directory - saved between application launches, but not supported by iTunes - you must place files there that can be easily restored by your program to improve the backup time of the device.

     NSString* cachesPath = [NSSearchPathForDirectoriesInDomains (NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0]; 
  • Temporary directory - may not be saved between application launches

     NSString* tempPath = NSTemporaryDirectory(); 
+8
source