2014-03-26 81 views
19

我嘗試使用AFNetworking多部分表單數據來上傳文件。我收到以下錯誤。我可以找出什麼是錯誤。將文件路徑轉換爲文件url [NSUrl]

[NSURL URLWithString:filePath] 還使用[[NSURL URLWithString:filePath] filePathURL],但不幫助我。 當我登錄文件路徑字符串:它顯示了正確的路徑:/var/mobile/Applications/3CBF5127-B2FF-49C3-AC98-16BD0886EEE7/Documents/20140326105108_slno.ma4

錯誤: @"NSLocalizedFailureReason" : @"Expected URL to be a file URL"

Questions:如何這個路徑字符串轉換爲file url

+0

看看'NSURL'的文檔。 – rmaddy

回答

55

你想用這個方法來代替:

+ (id)fileURLWithPath:(NSString *)path 
22

嘗試這種方式。

NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath]; 

    //OR ... Use ` 

+[NSURL fileURLWithPath:] 

OR看看NSURL Class Reference

希望它可以幫助你。

相關問題