【发布时间】:2016-04-19 11:38:12
【问题描述】:
我制作了一个应用程序,它使用“writeToURL”在附加到资源的 txt 文件上写入文本。当我在模拟器上加载应用程序时,它会写入您输入的文本,但是当您在设备上启动应用程序时,它什么也不会写入。如果你在 txt 文件上写了一些东西,设备上加载的应用程序会显示它,但它不能像模拟器一样覆盖它...... 有什么问题? 谢谢! 代码(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 的详细信息
标签: ios objective-c simulator