LoginSignup
2
1

More than 5 years have passed since last update.

Swift3で[_SwiftValue pointSize]でのクラッシュを解決する

Posted at

最初どこでクラッシュしているのかもわからなかったけど、NSMutableAttributedStringに渡すために、NSFontAttributeNameをキーとしてフォントを指定している箇所だった。

このようにしているとクラッシュする。

let attrs = [
  NSFontAttributeName : UIFont.systemFont(ofSize: 15.0)
]

[String : Any]と明示的に宣言するとクラッシュしない。

let attrs: [String : Any] = [
  NSFontAttributeName : UIFont.systemFont(ofSize: 15.0)
]

他にもObjective-C時代にNSDictionaryを渡すべきだったところは、[String : Any]にすると無難なようである。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1