Setting NSUnderlineStyle causes unrecogognized selector exception
Swift 5 version of Vlad Khambir answer,
let attributes = [NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue]
Change line:
let attributes = [NSUnderlineStyleAttributeName:NSUnderlineStyle.styleSingle]
to:
let attributes = [NSUnderlineStyleAttributeName:NSUnderlineStyle.styleSingle.rawValue]