我做了一個應用程序,它使用「writeToURL」在附加到資源的txt文件上寫入文本。當我在模擬器上加載應用程序時,它會寫入您輸入的文本,但是當您在設備上啓動應用程序時,它什麼都不寫。如果你有一些寫在txt文件上的東西,裝載在設備上的應用程序會顯示它,但它不能覆蓋它,因爲模擬器不會... 什麼可能是錯誤的? Thx! 代碼(iOS的目標C):代碼在模擬器上工作,但不在設備上
-(IBAction)cargarALaWeb:(id)sender{
if ([_texto.text isEqualToString:[NSString stringWithFormat:@""]]) {
[_web1 loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://contactonotpad.wix.com/inicio#!ayuda-con-cargar-en-la-web/ak5ig"]]];
}
else{
NSString *textofile=_texto.text;
[textofile writeToURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"web" ofType:@"html"]] atomically:YES encoding:NSUTF8StringEncoding error:nil];
NSLog(@"Escrito");
[_web1 loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"web" ofType:@"html"]]]];
}
}
`
爲您正在使用的實際語言標記問題,並顯示您正在使用的代碼。包括您試圖寫入的URL的詳細信息 – Wain