小编Sir*_*III的帖子

让一个脚本等到最后一个脚本完成

我有一个脚本,它有两个苹果脚本,可以打开一个新选项卡并执行命令。我希望第二个苹果脚本等到第一个苹果脚本的命令行操作完成。在它继续之前,我宁愿不必只睡 x 久。

有没有办法做到这一点?

这是我所拥有的:

 osascript -e 'tell application "Terminal" to activate' \
 -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' \
 -e 'tell application "Terminal" to do script "cd '$current_dir'" in selected tab of the front window' \
 -e 'tell application "Terminal" to do script "./my_script arg1" in selected tab of the front window'

 ------ Wait until this process is finished -------

 osascript -e 'tell application "Terminal" to activate' \
 -e 'tell …
Run Code Online (Sandbox Code Playgroud)

shell applescript

5
推荐指数
1
解决办法
6577
查看次数

我可以获得iOS中GPS定位的准确性吗?

我见过Android开发人员可以获得GPS位置的准确性.有没有办法让我在iOS中获得我当前GPS定位的准确性?

我正在使用答案中的代码来获取我的位置:

 locationManager = [[CLLocationManager alloc] init];
 locationManager.delegate = self;
 locationManager.distanceFilter = kCLDistanceFilterNone;
 locationManager.desiredAccuracy = kCLLocationAccuracyBest;
 [locationManager startUpdatingLocation];


 - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
     NSLog(@"OldLocation %f %f", oldLocation.coordinate.latitude, oldLocation.coordinate.longitude);
     NSLog(@"NewLocation %f %f", newLocation.coordinate.latitude, newLocation.coordinate.longitude);
 }
Run Code Online (Sandbox Code Playgroud)

iphone gps cllocationmanager cllocation ios

5
推荐指数
2
解决办法
6611
查看次数

如何在Swift中获得Bool的相反值?

我的具体情况是我试图切换导航栏隐藏和显示.

    let navHidden = !self.navigationController?.navigationBarHidden
    self.navigationController?.setNavigationBarHidden(navHidden!, animated: true)
Run Code Online (Sandbox Code Playgroud)

对我来说不像通常在Obj-C中那样.

boolean ios swift

5
推荐指数
1
解决办法
1万
查看次数

从tap中获取UILabel中的角色索引

我想得到UILabel上的tapped字符的索引.我已经将UILabel分类了.在我的awakeFromNib()中我有这个:

    layoutManager = NSLayoutManager()
    textStorage = NSTextStorage(attributedString: self.attributedText)
    textStorage.addLayoutManager(layoutManager)

    textContainer = NSTextContainer(size: CGSizeMake(self.frame.size.width, self.frame.size.height))
    textContainer.lineFragmentPadding = 0
    textContainer.maximumNumberOfLines = self.numberOfLines
    textContainer.lineBreakMode = self.lineBreakMode
    textContainer.size = self.frame.size

    layoutManager.addTextContainer(textContainer)
Run Code Online (Sandbox Code Playgroud)

这是我想要它的标签的前5个字符的方式,因为我点击第一个字符,在我的touchesEnded我得到一个0的索引:

var touchedCharacterIndex = layoutManager.characterIndexForPoint(touch.locationInView(self), inTextContainer: textContainer, fractionOfDistanceBetweenInsertionPoints: nil)

但是当我点击UILabel的前四个字符的任何地方时,我得到4或0,这是不正确的.

谢谢,

更新

根据评论中的建议,我添加了这个:

 func updateTextStorage() {
    if let attributedText = self.attributedText {
        textStorage = NSTextStorage(attributedString: attributedText)
    }
    textStorage?.addLayoutManager(layoutManager)

    textContainer = NSTextContainer(size: CGSizeMake(self.frame.size.width, self.frame.size.height))
    textContainer?.lineFragmentPadding = 7
    textContainer?.maximumNumberOfLines = self.numberOfLines
    textContainer?.lineBreakMode = self.lineBreakMode
    textContainer?.size = self.bounds.size

    layoutManager.addTextContainer(textContainer!)
    layoutManager.textStorage = textStorage
}
Run Code Online (Sandbox Code Playgroud)

我称这种现象layoutSubviews(), …

nslayoutmanager uilabel ios nstextstorage nstextcontainer

4
推荐指数
2
解决办法
2761
查看次数

类模板的"类没有构造函数"错误

我正在创建一个链表,我只想在列表的前面添加一个节点.我究竟做错了什么?

Node.h

 #pragma once

 namespace list_1
 {
template <typename T>
struct Node
{
    T data;
    Node<T> *next;

    // Constructor
    // Postcondition: 
    Node<T> (T d);
};

template <typename T>
Node<T>::Node(T d)
{
    data = d;
    next = NULL;
}
 }
Run Code Online (Sandbox Code Playgroud)

list.h

template <typename T>
void list<T>::insert_front(const T& entry)
{
    Node<T> *temp = head;

    if(temp == NULL)
        temp->next = new Node(entry);
    else
    {
        while (temp->next != NULL)
        {
           temp = temp->next;
        }

        temp->next = new Node(entry);
    }
}
Run Code Online (Sandbox Code Playgroud)

错误信息;

 1>------ Build started: …
Run Code Online (Sandbox Code Playgroud)

c++ linked-list insert

3
推荐指数
1
解决办法
3211
查看次数

在 Node.js 服务器上接受请求正文中的二进制文件

我想在 .txt 文件的正文中上传一个二进制文件POST

我不想使用multipart/form-data.

(据我所知,multipart/form-data对于网络应用程序来说这是一种易于使用的技术,但对于移动应用程序来说并不容易。我没有网络应用程序,我只是构建移动应用程序。)

我尝试过使用busboy,但在非上传方面找不到任何内容multipart/form-dataexpress-fileuploadAFAIK 也使用同样的东西。

file-upload node.js busboy

3
推荐指数
1
解决办法
3502
查看次数

弗兰克设置错误,

我正在尝试使用这套说明设置frank-cucumber .

这样做之后:

sudo gem install frank-cucumber

我收到一个错误说:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:230:in activate: can't activate i18n (= 0.6.1, runtime) for ["activesupport-3.2.13", "xcodeproj-0.5.5", "frank-cucumber-1.1.8"], already activated i18n-0.6.4 for ["frank-cucumber-1.1.8"] (Gem::LoadError)

ruby terminal gem cucumber ios

2
推荐指数
1
解决办法
521
查看次数

检查一个字符串是否包含Ruby中多次出现的字符?

我想确保字符串具有ip地址的格式.我不需要太具体的东西.我只想检查.字符串中是否有三个.我可以检查那里是否.有这样的:

 str.include? '.'
Run Code Online (Sandbox Code Playgroud)

但是如何检查多个.

谢谢!

ruby string

2
推荐指数
3
解决办法
1426
查看次数

如何检查设备是4还是4​​?

如何检查设备是4还是4​​?

有没有办法让我这样做?我想检查,因为我使用的是UINavigationBar模糊,对于我的情况,如果没有模糊,它看起来不太好,所以如果它是iPhone 4,我会改变它.

iphone device ios

2
推荐指数
1
解决办法
1654
查看次数

如何撤消尚未推送的提交?

我做了两次提交而没有推它们.已经有多个其他提交被推送到我的分支机构.我还没有撤回这些提交.我想要销毁我没有被推送的两个提交,然后只获得其他人推送的其他多个提交.有人可以帮我弄这个吗?

我想一个接一个地反转这两个提交.但我想保留其他变化.这会有用吗?

git version-control github

2
推荐指数
1
解决办法
4706
查看次数