Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VKSdk how to set delegate in Swift?

Tags:

ios

swift

vk

I'm trying to make VKSdk work with Swift. Documentation says that I need to set delegate and in order to do this I have to do the following in Objective-c

VKSdk *sdkInstance = [VKSdk initializeWithAppId:YOUR_APP_ID];
[sdkInstance registerDelegate:delegate];
[sdkInstance setUiDelegate:uiDelegate];

In swift I try to do it like this

override func viewDidLoad() {
    super.viewDidLoad()

    VKSdk.initializeWithAppId("1111111")
    VKSdk.registerDelegate(self)


}

But it says Cannot convert value of type "ViewController" to expected argument type "VKSdk"

How to do this correctly ?

like image 668
Alexey K Avatar asked Nov 19 '25 18:11

Alexey K


1 Answers

Working code below

let sdk = VKSdk.initializeWithAppId("111111")
sdk.registerDelegate(self)
like image 65
Alexey K Avatar answered Nov 22 '25 08:11

Alexey K



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!