酢ろぐ!

カレーが嫌いなスマートフォンアプリプログラマのブログ。

Swiftで'_' is not convertible to 'StringLiteralConvertible'が発生したとき

'_' is not convertible to 'StringLiteralConvertible'が発生したとき。

        var hoge = [
            "duration": 0.5,
            "easing": "EasingInOutBounce",
            "transform": CGAffineTransformMakeScale(1.4, 1.4)
        ]
        var image = UIImage(named: "image_name")
        var hoge = [
            "duration": 0.5,
            "image": image
        ]

これでなおった。

        var hoge = [
            "duration": 0.5,
            "easing": "EasingInOutBounce",
            "transform": NSValue(CGAffineTransform: CGAffineTransformMakeScale(1.4, 1.4))
        ]

        var image = UIImage(named: "image_name")
        var hoge = [
            "duration": 0.5,
            "image": image!
        ]