Skip to content

Instantly share code, notes, and snippets.

@ldong
Created February 10, 2017 20:27
Show Gist options
  • Save ldong/75aa363a948355e1b264c38f7df227cd to your computer and use it in GitHub Desktop.
Save ldong/75aa363a948355e1b264c38f7df227cd to your computer and use it in GitHub Desktop.
// 获取沙盒主目录路径
NSString *homeDir = NSHomeDirectory();
// 获取Documents目录路径
NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
// 获取Library的目录路径
NSString *libDir = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) lastObject];
// 获取Caches目录路径
NSString *cachesDir = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
// 获取tmp目录路径
NSString *tmpDir =  NSTemporaryDirectory();

NSLog(@"%@",[[NSBundle mainBundle] bundlePath]);
NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"apple" ofType:@"png"];
UIImage *appleImage = [[UIImage alloc] initWithContentsOfFile:imagePath];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment