我正在嘗試加載uiwebview
中的網頁。 現在該頁面基於json
文件管理內容。寫入應用程序沙箱中的文件問題IOS
此文件也是通過對Web服務進行擴展評估來填充的。 我在做什麼是我使用Web服務填充此json文件並在頁面上顯示此內容web view
上顯示。
但問題是它工作正常,當我在模擬器上執行它。 但它不適用於我的設備。
這裏是代碼。 我會重點關注相關行。
NSURL *jsonURL=[NSURL URLWithString:@"http://r099:8080/WebServiceforiPad/rest/ipad/content/login/"];
// NSLog(@"%@",jsonSourcePathName);
NSString *jsonfileString=[NSString stringWithContentsOfURL:jsonURL encoding:NSASCIIStringEncoding error:nil];
NSLog(@"%@",jsonfileString);
NSString *documentDirectory=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *jsonFilePath=[documentDirectory stringByAppendingPathComponent:@"b2b_capability_eris.json"];
NSLog(@"###########%@",documentDirectory);
[jsonfileString writeToFile:jsonFilePath atomically:YES encoding:NSStringEncodingConversionAllowLossy error:nil];
我想你沒有.json文件在你的文檔目錄中 – Tendulkar
可能是URL不是全局的。意味着它是我認爲的本地系統。 –
@Tendulkar正確我的文件不在文檔目錄中... 但如果我把它放在文檔目錄中,它將不會被我的網頁訪問,然後... –