Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No '|' candidates produce the expected contextual result type 'NSTextStorageEditActions'

Tags:

ios

swift

I went through the Text Kit Tutorial on raywenderlich.com and the line

edited(.EditedCharacters | .EditedAttributes, range: range, changeInLength: (str as NSString).length - range.length)

produces the following error:

No '|' candidates produce the expected contextual result type 'NSTextStorageEditActions'

The error goes away when I change the first argument to:

edited(.EditedCharacters, range: range, changeInLength: (str as NSString).length - range.length)

I also tried using "OR" and "||" without any success.

Swift 2.2 and iOS 9.2

like image 989
Morgan Avatar asked Apr 11 '16 22:04

Morgan


2 Answers

@dfri is correct. To illustrate another example of using the pipe, "|", is when doing the autoResizingMask for UIImageView as follows:

imageView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight, ...]

Of course you'd replace the ... with other UIViewAutoresizing options.

Good luck!

like image 164
kbpontius Avatar answered Nov 07 '22 03:11

kbpontius


Put them all in an array like below:

instead of pipe

let timeDateComponents = calendar.components(NSCalendarUnit.Hour| NSCalendarUnit.Minute| NSCalendarUnit.Second, fromDate: NSDate())

try this

let timeDateComponents = calendar.components([NSCalendarUnit.Hour, NSCalendarUnit.Minute, NSCalendarUnit.Second], fromDate: NSDate())
like image 2
Arjun Kalidas Avatar answered Nov 07 '22 03:11

Arjun Kalidas