gpt4 book ai didi

ios 在 NSMutableURLRequest 上崩溃

转载 作者:行者123 更新时间:2023-11-29 13:37:11 25 4
gpt4 key购买 nike

NSURL *url = [NSURL URLWithString:@"http://locationofurlonlocalhost.mp4"];

...

NSMutableURLRequest *req;
req = [NSMutableURLRequest requestWithURL:url // <-- CRASH IS HERE!! thx to a breakpoint stepthrough
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:30.0];

url 的日志将导致:

Printing description of url:
<NSURLRequest http://locationofurlonlocalhost.mp4>

崩溃将记录

-[NSURLRequest absoluteURL]: unrecognized selector sent to instance 0x88003e0

URL 看起来很好,所以我不确定发生了什么。这会发生是因为模拟器无法访问 url 吗?我可以连接到 sim 的 safari 以及我的桌面 safari 上的 url。我该怎么办?

** 编辑 **

已确定 url 对象发布得太早。在 ... 中,url 被传递给不同的选择器,然后其余代码在那里发生。我怎样才能强制保留网址?我已经试过了:

__strong NSURL *url = [[NSURL alloc] initWithString:@"http://locationofurlonlocalhost.mp4"];

最佳答案

这绝对看起来像是您的网址已以某种方式发布。如果您打印 url 变量的描述并以 NSURLRequest 结束,那么您正在查看释放的内存。

尝试使用 alloc/initWithString: 作为故障排除步骤。

关于ios 在 NSMutableURLRequest 上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10271185/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com