首页 > 编程知识 正文

ios终于解决了微信延迟(ios performSelector延迟调用及取消问题)

时间:2023-05-05 18:12:22 阅读:123540 作者:3094

iOS延迟呼叫NSObject提供的相关函数如下:/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *。 in performselector:(sel ) aselectorwithobject: ) nullableid ) anargumentafterdelay: ) ns时间间隔) delayinmodelay selectorwithobject : (空id ) anargumentafterdelay 3360 (ns时间间隔) delay 3360 (ns时间间隔) ) 65 (void ) 360 (id atargetselector : (sel ) aselectorobject 3360 (nullable id ) )。 (void ) cancelpreviousperformrequestswithtarget : (id ) aTarget; @end 1, 延迟执行函数-(void ) performselector:(sel ) aselectorwithobject: ) nullableid ) anargumentafterdelay3360 ) nstiming-- with object : (空id ) anargumentafterdelay 3360 (ns时间间隔) delay 3360 (ns时间间隔) ) 65 2, 取消延迟函数(void ) cancelpreviousperformrequestswithtarget : ) atargetselector:(sel ) aselectorobject3360 ) nulll (void ) cancelpreviousperformrequestswithtarget : (id ) atargetselector:(sel ) aselectorobject3360 (空id ) )

此函数可以取消对带参数延迟函数的调用; (void ) cancelpreviousperformrequestswithtarget : (id ) aTarget;

此函数可以取消所有延迟调用;注意:通常在关联API的协调调用中没有任何问题,但在cancelpreviousperformrequestswithtarget 3360中扫描performSelector :出现的函数

随后调查结果显示,运行cancelpreviousperformrequestswithtarget:API时,已经在子线程中,然后切换到主线程后一切都可以!

-(void ) canceldealythread (dispatch _ async ) dispatch_get_main_queue ),^ { [ nsobjectcancelpreviousperformrrreue }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。