//获取家目录路径的函数: NSString *homeDir = NSHomeDirectory(); ///document NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);//程序主目录 NSString *documentDic = [paths objectAtIndex:0]; //cache NSArray *paths1 = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); NSString *cache = [paths1 objectAtIndex:0]; //获取tmp目录路径的方法: NSString *tmpDir = NSTemporaryDirectory(); //获取应用程序程序包中资源文件路径的方法:例如获取程序包中一个图片资源(apple.png)路径的方法: NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"apple" ofType:@"png"]; UIImage *appleImage = [[UIImage alloc] initWithContentsOfFile:imagePath];