gpt4 book ai didi

iphone - 当 View Controller 被弹出时,处理 RestKit 请求的正确方法是什么?

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

我在导航 Controller 中有一个 HTTP 请求:

[[RKClient sharedClient] get:url delegate:self];

但是如果用户在请求仍在运行时按下后退按钮,应用程序就会崩溃:

*** -[UITableView retain]: message sent to deallocated instance 0xeab5600

我在viewWillUnload(和viewDidUnload)中添加了以下代码来取消请求,但得到了相同的错误:

[[RKClient sharedClient].requestQueue cancelRequestsWithDelegate:self];

请帮忙。谢谢。

最佳答案

我发现当从导航 Controller 弹出 View 时,viewDidUnload和viewWillUnload没有被触发。所以我将cancelRequestsWithDelegate方法移至viewWillDisappear来解决该问题。

关于iphone - 当 View Controller 被弹出时,处理 RestKit 请求的正确方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12435931/

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