if (![tbxCreateFolder.text isEqualToString:@""]) {NSArray *arrPaths = NSSearchPathForDirectorIEsInDomains(NSdocumentDirectory,NSUserDomainMask,YES);Nsstring *documentsDirectoryStr = [arrPaths objectAtIndex:0]; // Get documents folderNsstring *dataPath = [documentsDirectoryStr stringByAppendingPathComponent:[Nsstring stringWithFormat:@"/%@",tbxCreateFolder.text]];if (![[NSfileManager defaultManager] fileExistsAtPath:dataPath]){ NSError* error; if([[NSfileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectorIEs:NO attributes:nil error:&error]){ NSLog(@"success"); //Perfrom DB Insertation } else { NSLog(@"[%@] ERROR: attempting to write create MyFolder directory",[self class]); NSAssert( FALSE,@"Failed to create directory maybe out of disk space?"); }}
}
NSArray *arrPaths = NSSearchPathForDirectorIEsInDomains(NSdocumentDirectory,YES);Nsstring *basePathString = ([arrPaths count] > 0) ? [arrPaths objectAtIndex:0] : nil;NSLog(@"dirContents %@",basePathString);
回应是:
/Users/amir/library/Application Support/iPhone Simulator/6.1/Applications/7003E8D5-CCBB-4E54-896B-F4BD2F4D2CB1/documents解决方法 这是代码:
Nsstring *documentDirPath = [NSSearchPathForDirectorIEsInDomains(NSdocumentDirectory,YES) objectAtIndex:0];// create directory named "test"[[NSfileManager defaultManager] createDirectoryAtPath:[documentDirPath stringByAppendingPathComponent:@"test"] withIntermediateDirectorIEs:YES attributes:nil error:nil];// retrIEved all directorIEsNSLog(@"%@",[[NSfileManager defaultManager] contentsOfDirectoryAtPath:documentDirPath error:nil]); NSArray *paths = [[NSfileManager defaultManager] contentsOfDirectoryAtPath:documentDirPath error:nil]; BOol isDir = NO; for (Nsstring *path in paths) { if ([fileManager fileExistsAtPath:path isDirectory:&isDir] && isDir) { // path is directory }}总结
以上是内存溢出为你收集整理的ios – 如何获取NSDocumentDirectory中的directores列表?全部内容,希望文章能够帮你解决ios – 如何获取NSDocumentDirectory中的directores列表?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)