XCode 6.1 NSString.boundingRectWithSize Compilation Error
After upgrading Xcode to 6.1, I am getting a couple of compiler errors for my existing project.
I have defined attributes like
let styleAttriutes = [
NSFontAttributeName : UIFont(...),
NSForgeroundColorAttributeName : UIColor.blackColor()
]
Error: "Could not find an overload for 'init' that takes the supplied arguments
So I declared that the introduced dictionary explicitly adds : [NSString: Any] , since all key constants are of type NSString
and we have different values: UIFont
/ UIColor
and is AnyObject
also not allowed.
let styleAttriutes : [NSString : Any] = [ ...
The compiler is now happy with this question.
Certain attributes are used in
text.boundingRectWithSize(size: CGSize, options: NSStringDrawingOptions, attributes: [NSObject : AnyObject!], context: NSStringDrawingContext!)
Since type attributes are expected [NSObject:AnyObject!]
, but I am passing in type attributes [NSString : Any]
, the compiler complains:
Error : "NSString" is not identical to "NSObject" "
I tried using it with help attributes as [NSObject : AnyObject]
, but then I get a runtime error.
Fatal error : "Cannot unsafe BitCast between types of size differences."
Any suggestions?
source to share