Does Swift support implicit conversion?

后端 未结 3 631
囚心锁ツ
囚心锁ツ 2020-11-30 05:31

For example, I have the following code:

    let numberOfBlocks = 3
    let blockWidth = SKSpriteNode(imageNamed: \"image.png\").size.width
    let padding =          


        
3条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 06:14

    using bridgeToObjectiveC() method you can call the methods provided in Objective - C to convert from one primitive data type to another for e.g.

    variable_name.bridgeToObjectiveC().intValue
    

    will convert that variable named variable_name to integer

提交回复
热议问题