Can anybody tell me what's wrong ?
let myTitle = NSAttributedString(string: Xdevices[row].deviceName!,
attributes: [NSFontAttributeName:UIFont(name: "Georgia", size:
15.0)!,NSForegroundColorAttributeName:UIColor.orangeColor(),
NSStrikethroughStyleAttributeName: NSUnderlineStyle.StyleSingle])
The error is:
Type of expression is ambiguous without more context
This happened after inserting NSStrikethroughStyleAttributeName: NSUnderlineStyle.StyleSingle
Try this:
let attributes = [
NSFontAttributeName: UIFont(name: "Georgia", size: 15.0)!,
NSForegroundColorAttributeName: UIColor.orangeColor(),
NSStrikethroughStyleAttributeName: NSNumber(integer: NSUnderlineStyle.StyleSingle.rawValue)
]
let myTitle = NSAttributedString(string: Xdevices[row].deviceName!, attributes: attributes)
NSAttributedString(string:attributes:)
expects a dictionary of type [String: AnyObject]
. Howeverm StyleSingle
is an Int
. Hence you must wrap it inside an NSNumber
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With