bash 判断字符串
判断字符串是否为整数
[[ "${str}" =~ ^-?[[:digit:]]*$ ]] //正则表达式 不能加引号
expr match "$str" "^-\?[0-9]*$"
判断字符串 包含 123
[[ "${str}" == *"123"* ]]
判断字符串是否为整数
[[ "${str}" =~ ^-?[[:digit:]]*$ ]] //正则表达式 不能加引号
expr match "$str" "^-\?[0-9]*$"
判断字符串 包含 123
[[ "${str}" == *"123"* ]]
获取osx下的键盘输入
NSKeyDown事件需要 申请权限
(System Preferences → Security & Privacy → Accessibility)
NSDictionary *dict=@{(__bridge NSString *)kAXTrustedCheckOptionPrompt:@YES};
BOOL istrue=AXIsProcessTrustedWithOptions((__bridge CFDictionaryRef)dict);
NSLog(@"%d",istrue);
方法1 cocoa