After I updated Xcode to 6.1 I get a couple of Compiler errors for my existing project.
I defined attributes like
let styleAttriutes = [
NSFontAttributeName : UIFont(...),
NSForgeroundColorAttributeName : UIColor.blackColor()
]
Error: "Could not find an overload for 'init' that accepts the supplied arguments"
So I declared the inferred Dictionary explicit adding : [NSString : Any] since all the key constants are of type NSString and we have different values: UIFont / UIColor and AnyObject is also not allowed.
let styleAttriutes : [NSString : Any] = [ ...
Now the compiler is happy in this point.
The defined attribues are used in
text.boundingRectWithSize(size: CGSize, options: NSStringDrawingOptions, attributes: [NSObject : AnyObject!], context: NSStringDrawingContext!)
Since attributes of type [NSObject:AnyObject!] are expected but I hand over attribues of type [NSString : Any] the compiler complains:
Error: "'NSString' is not identical to 'NSObject'"
I tried to cast it using attributes as [NSObject : AnyObject] but then I get runtime error.
Fatal Error: "Can't unsafeBitCast between types of differenz sizes".
Any suggestions?
I guess you're using UIFont's init method which returns an optional (i.e. can return nil) since Xcode 6.1.
So try replacing UIFont(...) with UIFont(...)!.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With