国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

RunLoop(基本操作)

2019-11-14 20:38:25
字體:
來源:轉載
供稿:網友

 

基本概念

 

-(void)runTimerInThread{    //NSAutoreleasePool,沒的用    [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(doSth:) userInfo:self repeats:YES];        //1.以上方法自動把NSTimer添加到RunLoop里面        NSTimer* timer=[NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(doSth:) userInfo:self repeats:YES];        //2.以上方法不會自動NSTimer添加到RunLoop里面    [[NSRunLoop currentRunLoop]addTimer:timer forMode:NSDefaultRunLoopMode];    //要手動加入runLoop,額額,類方法就寫入了 addTimer:timer forMode:NSDefaultRunLoopMode;            [[NSRunLoop currentRunLoop]run];    //這很重要,把定時器的線程加入運行回環runloop才會使線程處于活躍狀態}

定時器要加入runLoop才可以正常運行,但是要保證定時器的精確度,必須在不堵塞的多線程下進行

 

 [self performSelectorInBackground:@selector(runTimerInThread) withObject:nil];

當然,你可以用CGD技術來處理多線程任務的

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 昌都县| 夹江县| 石嘴山市| 通海县| 浑源县| 江安县| 密云县| 遂川县| 敦煌市| 屏边| 阳泉市| 章丘市| 新民市| 山东| 万山特区| 祥云县| 汝城县| 崇文区| 建始县| 湟中县| 马尔康县| 大埔县| 通辽市| 郸城县| 冕宁县| 江北区| 新巴尔虎右旗| 石泉县| 平安县| 天等县| 小金县| 大理市| 樟树市| 大田县| 通榆县| 武功县| 西盟| 喀什市| 东乌珠穆沁旗| 诸城市| 赤峰市|