iPhone 在特定设备上崩溃

发布于 2024-11-26 09:13:27 字数 404 浏览 4 评论 0原文

我的应用程序包括滚动视图/页面控制,并从网络获取图像并显示在滚动视图上。它在 ipod 2nd Gen 和模拟器上运行良好,但在 Iphone 3GS 上有些崩溃。显然它在

NSData *htmlData = [[NSString stringWithContentsOfURL:[NSURL URLWithString:url] 
                            encoding:NSASCIIStringEncoding error:&error]
                            dataUsingEncoding:NSUTF8StringEncoding];

这条线上崩溃了。我不知道什么会导致它崩溃,因为它在其他设备和模拟器上运行顺利。任何帮助将不胜感激。

My app includes scrollview/pagecontrol and get image from web and display on scrollview. It works fine on ipod 2nd Gen and Simulator but somewhat it crashes on Iphone 3GS. Apparently it crashes on

NSData *htmlData = [[NSString stringWithContentsOfURL:[NSURL URLWithString:url] 
                            encoding:NSASCIIStringEncoding error:&error]
                            dataUsingEncoding:NSUTF8StringEncoding];

this line. I have no idea what would cause to crash on it since it works smoothly on other device and simulator. Any help would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

匿名。 2024-12-03 09:13:27

看来您将 NSString 的编码指定为 NSASCIIStringEncoding,但数据为 NSUTF8StringEncoding - 尝试使这两者相同,并查看错误是否仍然出现。

It seems that you specify the encoding of the NSString to be NSASCIIStringEncoding, but the data to be NSUTF8StringEncoding - try making both of these the same, and see if the error still occurs.

勿挽旧人 2024-12-03 09:13:27

您能向我们展示您的回溯吗?

NSString* myurl = @"http://example.com";
NSURL* url = [NSURL urlWithString:myurl];
NSString* urlContents = [NSString stringWithContentsOfURL:url encoding:NSUTF8Encoding error:nil];

我猜问题不在于 2G 和 3G。
您的编码问题使用其他编码格式,例如: NSASCIIStringEncoding

Can you show us your traceback

NSString* myurl = @"http://example.com";
NSURL* url = [NSURL urlWithString:myurl];
NSString* urlContents = [NSString stringWithContentsOfURL:url encoding:NSUTF8Encoding error:nil];

I guess issue is not with the 2G and 3G.
the problem with your encoding use other encoding format for ex: NSASCIIStringEncoding

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文