我将代码从XCode 6.4迁移到7,这个错误似乎无法解决。
func onHoldReasonAttributedTextSetup(onHoldReson : String) -> NSMutableAttributedString
{
let markerFontAttributes : [NSObject : AnyObject]? = [
NSFontAttributeName : UIFont(name: "HelveticaNeue", size: 12.0)!,
NSForegroundColorAttributeName : UIColor(red: 0/255, green: 152/255, blue: 204/255, alpha: 1.0)
]
let onHoldText = NSAttributedString(string: "On Hold: ", attributes: markerFontAttributes)
let onHoldReasonText = NSAttributedString(string:onHoldReson)
var string = NSMutableAttributedString()
string.appendAttributedString(onHoldText)
string.appendAttributedString(onHoldReasonText)
return string
}
答案 0 :(得分:1)
您需要更改此行:
let markerFontAttributes : [NSObject : AnyObject]? = [
NSFontAttributeName : UIFont(name: "HelveticaNeue", size: 12.0)!,
NSForegroundColorAttributeName : UIColor(red: 0/255, green: 152/255, blue: 204/255, alpha: 1.0)
]
到
let markerFontAttributes : [String : AnyObject]? = [
NSFontAttributeName : UIFont(name: "HelveticaNeue", size: 12.0)!,
NSForegroundColorAttributeName : UIColor(red: 0/255, green: 152/255, blue: 204/255, alpha: 1.0)
]
因为初始化程序需要[String : AnyObject]?
格式的字典:
init(string str: String, attributes attrs: [String : AnyObject]?)