Charts: Type 'NSAttributedStringKey' (aka 'NSString') has no member 'font'

Created on 22 Sep 2017  ·  12Comments  ·  Source: danielgindi/Charts

When updated Charts to 3.0.4 getting this error in Xcode 9.

Other errors are:

  1. Incorrect argument label in call (have 'withAttributes:', expected 'attributes:')
  2. Cannot convert value of type '[NSAttributedStringKey : Any]?' (aka 'Optional>') to expected argument type '[String : Any]?'

Most helpful comment

I also noticed this. I fix it by setting swift version to 4.0 in the charts build settings in xcode
screen shot 2017-09-22 at 09 42 09

All 12 comments

I am also facing errors in most of the Charts classes after updating to 3.0.4

Incorrect argument label in call (have 'withAttributes:', expected 'attributes:')

I also noticed this. I fix it by setting swift version to 4.0 in the charts build settings in xcode
screen shot 2017-09-22 at 09 42 09

I also fixed it. Thank You

how to fix in an ObjectiveC project?

it should have @objc tag to use, so update your code

attributes: [NSFontAttributeName: label.font]

For Swift 3 use pod 'Charts','= 3.0.3'

I guess this should be fixed in this framework.

Btw, if using Pods:

  1. Select the Pods project in the left-most viewer in Xcode.
  2. Select Charts target.
  3. Build Settings
  4. Swift Language Version

Ran into this problem with v. 3.1.1, I'm using Swift 4.1

let att: [NSAttributedStringKey: Any] = [

        NSAttributedStringKey(rawValue:

NSAttributedStringKey.font.rawValue) : UIFont.italicSystemFont(ofSize: 15.0
),

        NSAttributedStringKey(rawValue:

NSAttributedStringKey.foregroundColor.rawValue) : Const.colorBlue500,

        NSAttributedStringKey(rawValue:

NSAttributedStringKey.underlineStyle.rawValue) : 1]

    let attributeString = NSMutableAttributedString(string:

"open_accessory_sheet".localize,

                                                    attributes: att)

For swift 4 .
you can try use it

Vào Th 7, 9 thg 6, 2018 vào lúc 02:43 Jose Manuel Vergara Florez <
[email protected]> đã viết:

Ran into this problem with v. 3.1.1, I'm using Swift 4.2


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/danielgindi/Charts/issues/2816#issuecomment-395868392,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMLGfjdadIXdyF4cgGGTCaYMQs1sz9CDks5t6tPcgaJpZM4PgNRb
.

let att: [NSAttributedStringKey: Any] = [
NSAttributedStringKey(rawValue: NSAttributedStringKey.font.rawValue) : UIFont.italicSystemFont(ofSize: 15.0),
NSAttributedStringKey(rawValue: NSAttributedStringKey.foregroundColor.rawValue) : Const.colorBlue500,
NSAttributedStringKey(rawValue: NSAttributedStringKey.underlineStyle.rawValue) : 1]
let attributeString = NSMutableAttributedString(string: "open_accessory_sheet".localize,
attributes: att)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brytnvmg picture brytnvmg  ·  4Comments

valeIT picture valeIT  ·  3Comments

heumn picture heumn  ·  3Comments

Aungbandlab picture Aungbandlab  ·  4Comments

sjdevlin picture sjdevlin  ·  3Comments