首先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. 1、在Centos上安装Grafana

    1.如果你想将老版本的Grafana升级为新版本的Grafana,可以阅读链接中的文档指南: http://docs.grafana.org/installation/upgrading/ 2.使用y ...

  2. jsp 安全

    一.  身份验证和授权 认证是检验某人真正是他/她自称的那个人的过 程.在一个Servlet/JSP应用程序中,身份验证一般通过 检查用户名密码是否正确.授权是检查该级别的用户是 否具备访问权限.它适 ...

  3. CentOS7.X首次安装docker无法启动的问题解决

    CentOS7.2 随着Docker的不断流行与发展,docker公司(或称为组织)也开启了商业化之路,Docker 从 17.03版本之后分为 CE(Community Edition) 和 EE( ...

  4. ~/Library/MobileDevice/Provisioning Profiles

    ~/Library/MobileDevice/Provisioning Profiles

  5. BZOJ4451 [Cerc2015]Frightful Formula 多项式 FFT 递推 组合数学

    原文链接http://www.cnblogs.com/zhouzhendong/p/8820963.html 题目传送门 - BZOJ4451 题意 给你一个$n\times n$矩阵的第一行和第一列 ...

  6. 远程连接你的linux服务器

    为什么要远程连接linux 在实际的工作场景中,虚拟机界面或者物理服务器本地的终端都是很少接触的,因为服务器装完系统之后,都要拉倒IDC机房托管,如果是购买的云主机,那更碰不到服务器本体了,只能通过远 ...

  7. css 浮动布局,清除浮动

    浮动的特性: (1)浮动元素有左浮动(float:left)和右浮动(float:right)两种 (2)浮动的元素会向左或向右浮动,碰到父元素边界.其他元素才停下来 (3)相邻浮动的块元素可以并在一 ...

  8. __http原理__01__通信流程_消息格式

    本文转自  菜鸟教程  一.HTTP协议(HyperText Transfer Protocol,超文本传输协议) 是因特网上应用最为广泛的一种网络传输协议, 是用于从万维网(WWW:World Wi ...

  9. opencv 常用头文件介绍

    1.OpenCV包含的模块 cv – 核心函数库 cvaux – 辅助函数库 cxcore – 数据结构与线性代数库 highgui – GUI函数库 ml – 机器学习函数库 2.常用头文件: #i ...

  10. ActivityRouter 框架简单实用

    ActivityRouter组件化开发小助手用法如下: 跟目录build.gradle dependencies { // activityRouter classpath 'com.neenbeda ...