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

NSString *documentsDirectory = [paths objectAtIndex:0];

// 创建文件系统管理器

NSFileManager *fileManager = [[NSFileManageralloc] init];

// 判断userData 目录是否存在

if(![fileManager fileExistsAtPath:[NSStringstringWithFormat:@"%@/userData",documentsDirectory]]) {

// 不存在创建一个userData目录

[fileManager createDirectoryAtPath:[NSStringstringWithFormat:@"%@/userData",documentsDirectory]              withIntermediateDirectories:false

attributes:nil

error:nil];

}