-(void )测试(ns log ) @'2); () void ) test2) nslog ) @'3); (void ) viewdidload([superviewdidload]; //并发队列dispatch _ queue _ tqueue=dispatch _ queue _ create (' batac.com ',DISPATCH_QUEUE_CONCURRENT ); //异步处理任务选中dispatch _ async (队列,^{ //异步并行队列处理任务是子线程处理任务nslog ) @'1)。 [ selfperformselector : @ selector (test ) with object : nilafterdelay :0 ] [ selfperformselector 3: @ selector (ttor ) ); }上述内容要打印什么? //1 3 4
原因: perform selector 3360 with object :方法使用消息发送机制,调用msg_send, 直接调用的perform selector : @ selector (test ) with object : nilafterdelay :方法的基础使用NSTimer实现,并在当前线程的运行loop中添加timer -(void )测试(ns log ) @'2); () void ) test2) nslog ) @'3); (void ) viewdidload([superviewdidload]; //并发队列dispatch _ queue _ tqueue=dispatch _ queue _ create (' batac.com ',DISPATCH_QUEUE_CONCURRENT ); //异步处理任务选中dispatch _ async (队列,^{ //异步并行队列处理任务是子线程处理任务nslog ) @'1)。 [ selfperformselector : @ selector (测试) with object : nilafterdelay :0 ] [ [ nsr unloop currentrunlooop ] run ] [ seller ); }
//打印结果: 1 2 3 4