奇怪的 NSURL 行为:baseUrl 始终设置为奇怪的值

发布于 2024-08-23 05:36:21 字数 562 浏览 2 评论 0原文

我有一个奇怪的行为: 在对代码进行一些更改后,我在 NSURL 中得到了一个未询问的 URL。实际上,这个 URL 在我昨天进行的测试中是有效的,但系统会记住这个 URL,即使在另一个应用程序中我也无法更改它。

当我使用以下代码strted一个新应用程序时:

int main(int argc, char *argv[]) {
    NSURL *URLurl = [NSURL URLWithString:@"http://www.google.com"];
    NSLog([URLurl absoluteString]);
}

baseUrl类似于:http:inl.co.il,即使我要求google.com, NSLog 是正确的并打印: http://www.google.com

但它对我没有帮助,因为base 是整个代码的工作对象。

奇怪的是,NSURL 从哪里获取这个旧的未使用的字符串?

有什么帮助吗?

谢谢

I have a strange behave:
After making a few changes in my code, I got an unasked URL in the NSURL. Actually, this URL was valid in a test I made yesterday, but the system remembers this URL and I cannot changed it even in another app.

When I strted a new app with the followung code:

int main(int argc, char *argv[]) {
    NSURL *URLurl = [NSURL URLWithString:@"http://www.google.com"];
    NSLog([URLurl absoluteString]);
}

the baseUrl is something like: http:inl.co.il, even I asked for google.com,
the NSLog is correct and prints: http://www.google.com

But it does not help me since the base is what the entire code works with.

And strangly, where from is that NSURL taking this old unused string?

Any help?

Thank you

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

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

发布评论

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

评论(1

娇女薄笑 2024-08-30 05:36:22

永远不要像这样直接在NSLog内部记录变量,因为任何百分比符号都很容易造成混乱。相反,应该这样做:

NSLog(@"%@", [URLurl absoluteString]);

缺乏进一步的信息,这可能是问题的根源。另外,编译器应该警告您,无论如何,您的原始声明是不可靠的。

Never log variables directly inside of NSLog like this, as any percent symbols will easily cause mayhem. Instead do:

NSLog(@"%@", [URLurl absoluteString]);

Lacking further information, this is probably the root of the problem. Also, the compiler should be warning you your original statement is dodgy, anyway.

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