Reputation: 565
In my swift code I use the peertalk objective-c library using a bridging-header.
In a delegate method I get some payload in a parameter with the type of UnsafeMutablePointer<Void>
.
How can I cast the payload to my struct type in Swift so I can use the data?
Upvotes: 1
Views: 1291
Reputation: 7741
Just a guess referencing from here
struct YourStruct {
var name : String
}
var structInstance = YourStruct.init(name: "Jose")
func delegateMethod(voidPtr : UnsafePointer<Void>) {
//CONVERSION HERE
let myStruct = UnsafePointer<YourStruct>(voidPtr).memory
print("\(myStruct.name)")
}
delegateMethod(&structInstance)
Upvotes: 3