3

以下のコードは、Xcode 6 beta 5 で正常に動作していました。

func fitText(){
    let size = (self.text as NSString).sizeWithAttributes([NSFontAttributeName:self.font]) //Errors here
    self.frame.size = size
}

これで、2 行目に次のエラーが表示されます。

「UIFont」は「NSDictionary」のサブタイプではありません

式の型 '$T6' を型 'UIFont' に変換できません

に分けたら

let dict = [NSFontAttributeName:self.font]
let size = (self.text as NSString).sizeWithAttributes(dict) //Even stranger errors go here

xcode 言います:

「UIFont」は「NSDictionary」のサブタイプではありません

式の型 '[NSString : UIFont]' を型 'CGSize' に変換できません

コードを壊すベータ 7 または 6 の Swift で何が変更されましたか?

4

2 に答える 2