NSFontAttributeName vs NSAttributedStringKey.font

Swift 4.2

NSAttributedStringKey renamed NSAttributedString.Key. However for this particular issue you need to get the raw value so the solution would be NSAttributedString.Key.font.rawValue

Take a look here for an in-depth explanation: https://stackoverflow.com/a/46459315/2440997


The projects are probably in different versions of Swift.

In Swift 4, NSFontAttributeName has been replaced with NSAttributedStringKey.font.

In Swift 5, NSFontAttributeName has been replaced with NSAttributedString.Key.font.

Tags:

Ios

Swift3