我想用NSURL URLWithString從一個非常長的文件名可能很長的文件路徑創建一個NSURL對象。當我使用URLWithString轉換爲NSURL對象的文件路徑,該路徑被縮短,省略號「......」被放在NSURL:NSURL URLWithString縮短很長的字符串,省略號「...」,創建無效的NSURL對象
Path as NSString: /var/mobile/Containers/Data/Application/APPLICATION_ID/Documents/TEMP/this_is_a_really_really_and_i_mean_reaeeeeaaaallly_long_file_name/this_is_a_really_really_and_i_mean_reaeeeeaaaallly_long_file_name.xml
// Convert to NSURL using this technique:
[NSURL URLWithString:pathAsString]
Path as NSUrl: /var/mobile/Containers/Data/Application/APPLICATION_ID/Documents/TEMP/this_is_a_really_really_and_ ... name.xml
我不能找到解決這個問題的任何方式,並我得到一個錯誤,當我嘗試打開在NSURL我試圖創建文件,說有沒有這樣的文件或目錄:
Error Domain=NSCocoaErrorDomain Code=260 "The operation couldn’t be completed. (Cocoa error 260.)" UserInfo=0x15ec82b0 {NSFilePath=/var/mobile/Containers/Data/Application/APPLICATION_ID/Documents/TEMP/this_is_a_really_really_and_ ... name.xml, NSUnderlyingError=0x15eac4a0 "The operation couldn’t be completed. No such file or directory"}
我不知道爲什麼要添加的省略號和我無法弄清楚如何解決這個問題。
你可以添加代碼如何生成路徑? – Tobias