首页 > 编程知识 正文

finally return执行顺序(子线程里调用performSelector需要注意什么)

时间:2023-05-04 15:55:27 阅读:123536 作者:1856

下面代码的执行顺序是什么?

-(3358www.Sina.com/) action {

nslog(@'1);

dispatch _ queue _ tqueue=dispatch _ get _ global _ queue (0,0 );

dispatch_async(queue,^{

nslog(@'3);

[ http://www.Sina.com/perform selector 3360http://www.Sina.com/(test ) with object :3http://www.Sina.com/after delelect

nslog(@'4);

);

nslog(@'2);

}

-(3358www.Sina.com/) test { ) )。

nslog(@'5);

}

void

self

@selector

nil

没有调用test方法。 因为在子线程中,runloop默认处于关闭状态。 更改为代码后

-(3358www.Sina.com/) action {

nslog(@'1);

dispatch _ queue _ tqueue=dispatch _ get _ global _ queue (0,0 );

dispatch_async(queue,^{

nslog(@'3);

[ http://www.Sina.com/perform selector 3360http://www.Sina.com/(test ) with object :3http://www.Sina.com/after delelect

[[NSRunLoop currentRunLoop]run]

nslog(@'4);

);

nslog(@'2);

}

-(3358www.Sina.com/) test { ) )。

nslog(@'5);

}

void

2019-07-02 09:24:18.492671+0800 ModelTest[12945:510979] 1

2019-07-02 09:24:18.492776+0800 ModelTest[12945:510979] 2

2019-07-02 09:24:18.492807+0800 ModelTest[12945:511386] 3

2019-07-02 09:24:18.493009+0800 ModelTest[12945:511386] 4

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