I just migrated our project to swift 3 and see lots of crashes because of one issue:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_SwiftValue pointSize]: unrecognized selector sent to instance
The reason for that error is the call to:
let attributes: [String: AnyObject?] = [
NSFontAttributeName: UIFont.systemFont(ofSize: 14)
let boundingRect = ("hello" as NSString).boundingRect(with: CGSize(width: 100, height: 100), options: .usesLineFragmentOrigin, attributes: attributes, context: nil)
If I use your test code, but let the data type of
attributes default, it doesn't crash. That is:
let attributes = [NSFontAttributeName: UIFont.systemFont(ofSize: 14)]
Option-clicking on the variable says it's
[String : UIFont].
A little extra testing, suggests that it's related to the optional object;
[String: AnyObject] appears to work OK.
And after all that, I decided to read the documentation, which says to use
[String: Any]. :)