SWIFT – NSFONTATTRIBUTEDSTRING Work before Xcode 6.1

let timeFont = [NSFontAttributeName:UIFont(name: "Voyage", size: 20.0)]
var attrString3 = NSAttributedString("(Time)", attributes: timeFont); // <--- compiler error "Extra argument in call"

This code runs in xcode 6.0, but now I have upgraded to xcode 6.1 it no longer works, I can’t get it Be clear about what I need to make it work again. It says there is an additional argument, but this is not correct. I believe it has to do with the new available initializer, but everything I have tried does not work.

< /div>

Xcode 6.1 comes with Swift 1.1, which supports constructors that may fail. UIFont initialization may fail and return zero. When creating NSAttributedString String is also used when:

if let font = UIFont(name: "Voyage", size: 20.0) {
let timeFont = [NSFontAttributeName:font ]
var attrString3 = NSAttributedString(string: "(Time)", attributes: timeFont)
}

let timeFont = [NSFontAttributeName :UIFont(name: "Voyage", size: 20.0)]
var attrString3 = NSAttributedString("(Time)", attributes: timeFont); // <--- compiler error "Extra argument in call"

This code runs in xcode 6.0, but now I have upgraded to xcode 6.1 it doesn't work anymore, I don’t How to figure out what I need to make it work again. It says there is an additional argument, but this is not correct. I believe it has to do with the new available initializer, but everything I tried didn't work.

Xcode 6.1 comes with Swift 1.1, which supports constructors that may fail. UIFont initialization may fail and return zero. String is also used when creating NSAttributedString:

if let font = UIFont(name: "Voyage", size: 20.0) {
let timeFont = [NSFontAttributeName:font]
var attrString3 = NSAttributedString( string: "(Time)", attributes: timeFont)
}

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4101 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.