Книга: iOS. Приемы программирования

Решение

Решение

Пользуйтесь методом экземпляра createDirectoryAtPath: withIntermediateDirectories: attributes: error:, относящимся к классу NSFileManager, как показано далее:

— (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(@"Successfully created the directory.");
} else {
NSLog(@"Failed to create the directory. Error = %@", error);
}
self.window = [[UIWindow alloc]
initWithFrame: [[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}

Оглавление книги


Генерация: 0.056. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз