Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting NSUnderlineStyle causes unrecogognized selector exception

Tags:

I am trying to underline a string with NSAttributed string. For some reason, my lines cause the exception:

-[_SwiftValue _getValue:forType:]: unrecognized selector sent to instance    

The result is supposed to be used for a UILabel within a UITableView and is created as needed.

This is the code:

attributedString = NSMutableAttributedString(string: message)  if let actor = event.actor {    let attributes = [NSUnderlineStyleAttributeName:NSUnderlineStyle.styleSingle]    var attributedActorString = NSMutableAttributedString(string: actor.shirtName, attributes: attributes)    attributedActorString.insert(NSAttributedString(string: " "), at: 0)    attributedActorString.append(NSAttributedString(string: ". "))                               attributedActorString.append(attributedImageStringForUrl(event.actor!.portraitImageUrl, indexPath: indexPath))    attributedString.append(attributedActorString) } 
like image 716
ff10 Avatar asked Sep 07 '17 08:09

ff10


1 Answers

Change line:

let attributes = [NSUnderlineStyleAttributeName:NSUnderlineStyle.styleSingle] 

to:

let attributes = [NSUnderlineStyleAttributeName:NSUnderlineStyle.styleSingle.rawValue] 
like image 191
Vlad Khambir Avatar answered Oct 01 '22 19:10

Vlad Khambir