iPhone本地文件路径
我在我的应用程序中集成了dropbox。我拥有它,它可以向用户显示文件,用户可以选择要下载的文件。我知道我需要拨打这条电话,但我不知道iPhone上的本地文件路径是什么。它只需要是暂时的,因为一旦我有了文本文件,我会处理它。。。我的问题是什么是本地文件路径。先谢谢你iPhone本地文件路径,iphone,objective-c,dropbox,Iphone,Objective C,Dropbox,我在我的应用程序中集成了dropbox。我拥有它,它可以向用户显示文件,用户可以选择要下载的文件。我知道我需要拨打这条电话,但我不知道iPhone上的本地文件路径是什么。它只需要是暂时的,因为一旦我有了文本文件,我会处理它。。。我的问题是什么是本地文件路径。先谢谢你 [[self restClient] loadFile:[filePaths objectAtIndex:indexPath.row] intoPath:localPath] 根据以下回答进行更新:::仍不工作 -(void)ta
[[self restClient] loadFile:[filePaths objectAtIndex:indexPath.row] intoPath:localPath]
根据以下回答进行更新:::仍不工作
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *localPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingString:[filePaths objectAtIndex:indexPath.row]];
[[self restClient] loadFile:[filePaths objectAtIndex:indexPath.row] intoPath:localPath];
NSLog(@"%@",[NSString stringWithContentsOfFile:localPath encoding:NSUTF8StringEncoding error:nil]);
}
您通常只使用本地文档目录 试试这个:
NSString*localPath=[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES)objectAtIndex:0]stringByAppendingString:[FilePath objectAtIndex:Indexath.row]]代码>您可能正在寻找:
NSString * tempPath = [NSSearchPathForDirectoriesInDomains(NSTemporaryDirectory(), NSUserDomainMask, YES) objectAtIndex:0];
NSString * yourFile = [filePaths objectAtIndex:indexPath.row];
if(yourFile != nil) {
NSString * filePath = [tempPath stringByAppendingPathComponent:yourFile];
}
else {
// Check your file
}
由于历史原因,早在Objective-C出现之前,Unix中就存在对临时目录的需求。因此,在我们的语言中获取临时目录的方法是在使用confstr的现有Unix方法的基础上精心设计的。为了您的方便,它也在NSPathUtilities中
NSString *tmpDirectory = NSTemporaryDirectory();
NSString *tmpFile = [tmpDirectory stringByAppendingPathComponent:@"temp.txt"];
由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“***-[NSPathStore2 stringByAppendingString::nil参数”是否确定[filePaths objectAtIndex:Indexath.row]
不为空?