NSApplicationSupportDirectory--大部分OS X应用程序注册信息的保存地


NSString *getBundleName(){

    NSDictionary *dir = [[NSBundle mainBundle] infoDictionary];

    return [dir objectForKey:@"CFBundleName"];

}


int main(int argc, const char * argv[]) {

    @autoreleasepool {

        // insert code here...

        

        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);

        NSString *appSupportDirectory = [paths objectAtIndex:0];

        appSupportDirectory = [appSupportDirectory stringByAppendingFormat:@"/%@", getBundleName()];

        NSLog(@"path:   %@", appSupportDirectory);

        //NSLog(@"path:   %@", paths);

        

        NSFileManager *fileManager = [NSFileManager defaultManager];

        BOOL flag = [fileManager fileExistsAtPath:appSupportDirectory];

        if (!flag) {

            flag = [fileManager createDirectoryAtPath:appSupportDirectory withIntermediateDirectories:YES attributes:nil error:nil];

            if (!flag) {

                appSupportDirectory = @"../Resourcest";

            }

        }

    }

    return 0;

}


你可能感兴趣的:(NSApplicationSupportDirectory--大部分OS X应用程序注册信息的保存地)