我浏览了Text Kit Tutorial上的raywenderlich.com和
行edited(.EditedCharacters | .EditedAttributes, range: range, changeInLength: (str as NSString).length - range.length)
产生以下错误:
No '|' candidates produce the expected contextual result type 'NSTextStorageEditActions'
当我将第一个参数更改为:
时,错误消失了edited(.EditedCharacters, range: range, changeInLength: (str as NSString).length - range.length)
我也尝试使用" OR"和" ||"没有任何成功。
Swift 2.2和iOS 9.2
答案 0 :(得分:48)
@dfri是对的。为了说明使用管道的另一个例子," |",是在为UIImageView执行autoResizingMask时,如下所示:
public boolean isComplete()
{
if (isPerfect(root))
return true;
return isComplete(root);
}
/**
*
* @param node
* @return
*/
private boolean isComplete(Node node)
{
if (height(node) > 1)
{
if (node.left != null && node.right != null && (height(node.left) == height(node.right)))
return isComplete(node.left) && isComplete(node.right);
else
return false;
}
}
当然,您可以将imageView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight, ...]
替换为其他...
选项。
答案 1 :(得分:2)
将它们全部放在如下所示的数组中:
而不是管道
let timeDateComponents = calendar.components(NSCalendarUnit.Hour| NSCalendarUnit.Minute| NSCalendarUnit.Second, fromDate: NSDate())
试试这个
let timeDateComponents = calendar.components([NSCalendarUnit.Hour, NSCalendarUnit.Minute, NSCalendarUnit.Second], fromDate: NSDate())