stringWithContentOfURL 返回一个空字符串
我的方法“[NSStrng stringWithContentOfURL:url]”有问题; 一切都工作得很好,直到我将网址从网址更改为 IP 地址,然后我得到了一个空字符串。 您有解决方案或想法吗? Thks
i have a problem with the method "[NSStrng stringWithContentOfURL:url]";
all things worked so fine until i change my url from a web address to an ip address with which i got an empty string.
Did you have a solution or an idea?
Thks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用返回错误状态的方法(例如
+stringWithContentsOfURL:encoding:error:
)并检查错误返回。更新:NSCocoaErrorDomain Code=256 是“NSFileReadUnknownError”,这意味着“文件读取错误,原因未知”(不是很有帮助)。 URL 可能有问题(路径名拼写错误、IP 地址错误等)。URL
中肯定支持数字 IP 地址,所以这不是问题。
另请参阅 iPhone - dataWithContentsOfURL:不适用于某些网址
Use a method that returns an error status (e.g.
+stringWithContentsOfURL:encoding:error:
) and check the error return.update: NSCocoaErrorDomain Code=256 is "NSFileReadUnknownError", which means "file read error, reason unknown" (not very helpful). Probably there's something wrong with the URL (misspelled pathname, wrong IP address, etc.)
Numeric IP addresses most definitely are supported in URLs, so that's not the problem.
see also iPhone - dataWithContentsOfURL: does not work for some URLs