iOS无法识别的选择器发送到实例错误

时间:2017-03-03 03:32:28

标签: ios swift wechat

我在LoginViewController上添加了一个按钮。 这是LoginViewComtroller中的代码

loginButton?.addTarget(self, action: #selector(LoginViewController.wechatLogin), for: .touchDown)

func wechatLogin()  {
    sendWXAuthRequest()  
}

func sendWXAuthRequest() {
    print("hello")
    let req: SendAuthReq = SendAuthReq()
    req.scope = "snsapi_userinfo,snsapi_base"
    WXApi.send(req)
}

func onResp(_ resp: BaseResp!) {
    print(resp)
}

以下是AppDelegate.swift中的代码

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        //register
        buildKeyWindow()
        let right =  WXApi.registerApp("My_Appid")
        print(right)
        return true
    }


    func application(_ application: UIApplication, handleOpen url: URL) -> Bool {
        return WXApi.handleOpen(url, delegate: self)
    }


    func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        return WXApi.handleOpen(url, delegate: self)
    }

当我第一次运行应用程序时,进入微信时会出现错误。 然后我第二次运行它,有一个错误,说“无法识别的选择器发送到实例”

The error description

1 个答案:

答案 0 :(得分:1)

尝试将您的建筑设置的-all_load中的-force_load更改为Other Linker Flags