我正试着从水龙头里得到一个字.以下函数sender
来自UIGesture
于UITextView
句子.
- (IBAction)printWordSelected:(id)sender {
NSLog(@"Clicked");
CGPoint pos = [sender locationInView:self.view];
UITextView *_tv = sentence;
NSLog(@"Tap Gesture Coordinates: %.2f %.2f", pos.x, pos.y);
//eliminate scroll offset
pos.y += _tv.contentOffset.y;
//get location in text from textposition at point
UITextPosition *tapPos = [_tv closestPositionToPoint:pos];
//fetch the word at this position (or nil, if not available)
UITextRange * wr = [_tv.tokenizer rangeEnclosingPosition:tapPos withGranularity:UITextGranularityWord inDirection:UITextLayoutDirectionRight];
NSLog(@"WORD: %@", [_tv textInRange:wr]);
}
Run Code Online (Sandbox Code Playgroud)
这是我已经拥有的,但它将单词输出为NULL
我的主目录中有一个隐藏文件.profile
,其内容如下:
MYSQL_HOME = /usr/local/mysql/bin/mysql
export PATH=$MYSQL_HOME/bin:$PATH
Run Code Online (Sandbox Code Playgroud)
以下命令有效:
$ /usr/local/mysql/bin/mysql
Run Code Online (Sandbox Code Playgroud)
但是mysql
没有。如何更改路径以使命令起作用?我已经安装了MAMP,但不确定如何使用。谢谢!
AWS CLI命令aws emr list-clusters
返回以下json.有没有办法通过bash或groovy我可以使用Name来获取Id?我不能只使用Id,因为我正在删除集群并使用相同的名称重建它们.所以我知道集群的名称是"my-cluster",我想以某种方式使用它来获取集群的Id.最后的情况是我实际上想要群集的公共DNS.
{
"Clusters": [
{
"Status": {
"Timeline": {
"ReadyDateTime": 1433200405.353,
"CreationDateTime": 1433199926.596
},
"State": "WAITING",
"StateChangeReason": {
"Message": "Waiting after step completed"
}
},
"NormalizedInstanceHours": 6,
"Id": "j-3SD91U2E1L2QX",
"Name": "my-cluster"
},
{
"Status": {
"Timeline": {
"ReadyDateTime": 1433200405.353,
"CreationDateTime": 1433199926.596
},
"State": "WAITING",
"StateChangeReason": {
"Message": "Waiting after step completed"
}
},
"NormalizedInstanceHours": 6,
"Id": "j-3S281UEK8L2LW",
"Name": "my-cluster2"
}
]
}
Run Code Online (Sandbox Code Playgroud) <?php session_start();
$_SESSION['loggedIn'] = "no";
echo "Logged In: ". $_SESSION['loggedIn'];
if($_SESSION['loggedIn']=="yes"):
echo "logged in";
}
else{
echo "not logged in";
}
?>
Run Code Online (Sandbox Code Playgroud)
我只是想检查会话"loggedIn"是或否,但程序不打印任何内容.
为什么不打印任何东西?