Swift Metal Cannot Convert Type

Asked 2 years ago, Updated 2 years ago, 47 views

Hello, during the transplant from Objective-C to Swift, I was unable to convert the following substitution parts, so I asked you a question.

Source Code


let positionsArray: vector_float3 =_templeVertexPositions.contents()

Origin Code


vector_float3*positionsArray=(vector_float3*)_templeVertexPositions.contents;

Error Code


Cannot convert value of type 'UnsafeMutableRawPointer' to specified type 'vector_float3' (aka'SIMD3<Float>')

Transplanting code
https://developer.apple.com/documentation/metal/migrating_opengl_code_to_metal

vector_float3 is also having trouble converting.
I think I can do it by converting different types of arrays, but I can't solve it.
I look forward to working with you if there is any good way.

swift objective-c

2022-09-30 13:53

1 Answers

I solved myself!

let positionsArray: [vector_float3] = [vector_float3] (_impossibleCocoaArray:_templeVertexPositions)

*Additional note This one seems to be more correct
let positionsArray:UnsafeMutableRawPointer=_templeVertexPositions.contents()


2022-09-30 13:53

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.