iOS7 Programming Cookbook 第十四章学习笔记

####Creating Folders on Disk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
//执行许多通用文件系统操作并隔离应用程序与底层文件系统
NSFileManager *fileManager = [[NSFileManager alloc] init];
//返回当前用户临时目录的路径。
NSString *tempDir = NSTemporaryDirectory();

NSString *imagesDir = [tempDir stringByAppendingPathComponent:@"images"];

NSError *error = nil;
if ([fileManager createDirectoryAtPath:imagesDir withIntermediateDirectories:YES attributes:nil error:&error]){

NSLog(@"成功创建目录.");
} else {
NSLog(@"创建目录失败 Error = %@", error);
}

self.window = [[UIWindow alloc]
initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}

Reference

坚持原创技术分享,您的支持将鼓励我继续创作!
0%