0

アプリにドロップボックスを統合しました。ファイルがユーザーに表示され、ダウンロードするファイルを選択できるようになりました。この行を呼び出す必要があることはわかっていますが、iPhone のローカル ファイル パスがわかりません。テキストファイルを取得したら処理するので、一時的なもので十分です...私の質問は、ローカルファイルパスです。前もって感謝します。

[[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]);

}
4

3 に答える 3

0

通常は、ローカルドキュメントディレクトリを使用します。

これを試して:

NSString *localPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingString:[filePaths objectAtIndex:indexPath.row]];

于 2012-08-23T19:05:56.977 に答える
0

歴史的な理由から、一時ディレクトリの必要性は Objective-C よりずっと前から Unix に存在していました。したがって、私たちの言語で一時ディレクトリを取得する方法は、confstr を使用する既存の Unix メソッドの上に作成されます。便宜上、NSPathUtilities にも含まれています。

NSString *tmpDirectory = NSTemporaryDirectory();
NSString *tmpFile = [tmpDirectory stringByAppendingPathComponent:@"temp.txt"];
于 2012-08-24T08:14:35.007 に答える
0

あなたはおそらく探しているでしょう:

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
}
于 2012-08-23T20:47:30.847 に答える