iOS获取程序目录的一些路径

获取沙盒目录路径的函数

NSString * homeDir = NSHomeDirectory();

 

获取Documents目录路径的方法

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString
*docDir = [paths objectAtIndex:0];

 

获取Caches目录路径的方法

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);

NSString * cachesDir = [paths objectAtIndex:0];

 

获取tmp目录路径的方法

NSString *tmpDir = NSTemporaryDirectory();

 

获取应用程序程序吧中资源文件路径的方法

NSString *imagePath = [[NSBundlemainBundle] pathForResource:@"apple"ofType:@"png"];

UIImage *appleImage = [[UIImage alloc] initWithContentsOfFile:imagePath];

 

posted @ 2012-10-19 17:50  茄瓜写程序  阅读(131)  评论(0)    收藏  举报