首先RunLoop相关博客参考这篇https://blog.csdn.net/lengshengren/article/details/12905627。

最近开发了一个mac上的命令行工具,我在主线程没有任何代码运行,而是开辟了三个queue去执行各自逻辑,导致执行下面代码时,即使我的三个queue全部运行完了,命令行仍旧没有结束掉。

   

while (condition)

{

  // waiting for new data

  if ([[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]])

  {

    // process current data

  }

}

 后来查看RunLoop详细运用时,发现正是因为我的主线程没有执行任何代码,导致没有正确返回,改成这样定时返回而不是之前的有代码执行才返回就没问题了。

[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate: [NSDate dateWithTimeIntervalSinceNow:1.0]];

  

NSRunLoop 在mac command line tool上的部分运用的更多相关文章

  1. How to Use Android ADB Command Line Tool

    Android Debug Bridge (adb) is a tool that lets you manage the state of an emulator instance or Andro ...

  2. Cordova 3.0 Plugin 安装 及"git" command line tool is not installed

    根据http://docs.phonegap.com/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface Windows命令行 ...

  3. JMeterPluginsCMD Command Line Tool

    There is small command-line utility for generating graphs out of JTL files. It behave just like righ ...

  4. Cookies with curl the command line tool

    w https://curl.haxx.se/docs/http-cookies.html curl has a full cookie "engine" built in. If ...

  5. xcode10对应的xcode command line tool编译的坑

    众所周知,xcode10新增的编译系统new build system会不支持一些老项目的编译,一般的做法是在Xcode编译配置Xcode->File->Project Settings/ ...

  6. Building Xcode iOS projects and creating *.ipa file from the command line

    For our development process of iOS applications, we are using Jenkins set up on the Mac Mini Server, ...

  7. 怎样安装Command Line Tools in OS x Mavericks&Yosemite(Without xcode)--转载

    How to Install Command Line Tools in OS X Mavericks & Yosemite (Without Xcode) Mac users who pre ...

  8. 18 Command Line Tools to Monitor Linux Performance

    By Ravi Saive Under: Linux Commands, Monitoring Tools On: December 26, 2013 http://www.tecmint.com/c ...

  9. cURL POST command line on WINDOWS RESTful service

    26down votefavorite 7 My problem: Running windows 7 and using the executable command line tool to cu ...

随机推荐

  1. Confluence 使用常见问题列表

    Confluence 6 管理 Atlassian 提供的 App 摘要: Confluence 用户可以使用桌面应用来编辑一个已经上传到 Confluence 的文件,然后这个文件自动保存回 Con ...

  2. windows下的node环境搭建

    node环境的搭建过程: 1.首先在nodejs.org官网上下载一个msi安装文件,安装(过程很简单,基本上是一路next) 2.安装完成后,简单测试下是否安装成功,在cmd下输入两个命令: nod ...

  3. Jmeter性能测试之参数化(二)

    Jmeter参数化主要有3种方式: 1. Add--> Pre Processors--> User Parameters 2. Add--> Config Element--> ...

  4. 金蝶K/3 审批相关SQL语句

    金蝶K/3 审批相关SQL语句 --http://127.0.0.1/lightApp/todocheckTask.aspx?AccID=84&&FClasstypeID=1071&a ...

  5. Python学习(三十四)—— Django之ORM之单表、联表操作

    一.单表查询API汇总 <1> all(): 查询所有结果 <2> filter(**kwargs): 它包含了与所给筛选条件相匹配的对象 <3> get(**kw ...

  6. phpstorm对laravel的一些使用技巧

    安装laravel插件,设置ctrl+alt+s 二 安装智能提示插件 composer require barryvdh/laravel-ide-helper 在config/app.php的pro ...

  7. 蓝桥杯 全球变暖(dfs)

    标题:全球变暖 [题目描述]你有一张某海域NxN像素的照片,"."表示海洋."#"表示陆地,如下所示: 其中"上下左右"四个方向上连在一起的 ...

  8. Spring Boot 项目实战(五)集成 Dubbo

    一.前言 上篇介绍了 Redis 的集成过程,可用于解决热点数据访问的性能问题.随着业务复杂度的提高,单体应用越来越庞大,就好比一个类的代码行数越来越多,分而治之,切成多个类应该是更好的解决方法,所以 ...

  9. 关于linux上部署定时python脚本

    遇到的坑: Python脚本中的文件操作,最好都用绝对路径, 文件头上写 #!/usr/local/bin/python3.6 ----------------------------------- ...

  10. MyBatis3系列__01HelloWorld

    # MyBatis作为一个ORM框架,其重要程度不用过多介绍.下面开始一起学习吧:本博客的编程方法与MyBatis官方文档基本一致:## 1.创建一个数据库mybatis_learn以及对应的表tbl ...