[ios] objc创建目录

需要在App目录 Library/Caches 下创建新目录, 

创建一个“Map” 目录

    NSFileManager *manager = [NSFileManagerdefaultManager];

    std::string cacheDirectory = CCFileUtils::sharedFileUtils()->getWriteablePath();

    NSString * cachePath = [NSString stringWithCString:cacheDirectory.c_str() encoding:NSUTF8StringEncoding];

  NSString * directory = [NSString stringWithUTF8String:"Map" ];

        NSString *mapPath = [cachePath stringByAppendingPathComponent:directory];

  //判断目录是否存在

        if (![manager fileExistsAtPath:mapPath])

        {

            NSError *error;

            BOOL a = [manager createDirectoryAtPath:mapPath withIntermediateDirectories:YESattributes:nilerror:&error];

        }

posted @ 2013-04-09 13:38  haroel  阅读(198)  评论(0编辑  收藏  举报