Using GLKMath from GLKit in Swift

前端 未结 3 1365
春和景丽
春和景丽 2020-12-02 00:14

So I\'m using a book called iOS Games by tutorials from Ray Wenderlich and trying to utilize some of the objective-C code found there to make the accelerometer control of a

3条回答
  •  忘掉有多难
    2020-12-02 00:22

    Swift has added union support in version 1.2. The fields in imported unions are read-only, even if declared with var, but can be passed to and from C functions as necessary.

    The release notes for Swift 1.2 imply that the fields may not be accessible at all, but they are still readable for at least the GLKit types:

    Swift can now partially import C aggregates containing unions, bitfields, SIMD vector types, and other C language features that are not natively supported in Swift. The unsupported fields will not be accessible from Swift, but C and Objective-C APIs that have arguments and return values of these types can be used in Swift. This includes the Foundation NSDecimal type and the GLKit GLKVector and GLKMatrix types, among others.

提交回复
热议问题