下面代码的执行顺序是什么?
-(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