TuyaInc / tuyasmart_home_ios_sdk

Tuya Smart iOS Home SDK
https://tuyainc.github.io/tuyasmart_home_ios_sdk_doc
50 stars 19 forks source link

override function get exception #39

Closed MimikFc7 closed 4 years ago

MimikFc7 commented 4 years ago

Hello, when i add override function from get wifi signal:

`func getWifiSignalStrength() { self.device?.getWifiSignalStrength(success: { print("get wifi signal strength success") }, failure: { (error) in if let e = error { print("get wifi signal strength failure: (e)") } }) }

// MARK: - TuyaSmartDeviceDelegate func device(_ device: TuyaSmartDevice!, signal: String!) {

}`

take exception :

unrecognized selector sent to instance 0xa777d538f873fb09 2019-12-17 22:37:03.890862+0300 HomeAlone[8529:2794962] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0xa777d538f873fb09'

delegate was added TuyaSmartDeviceDelegate

TuyaRonbin commented 4 years ago

Can you provide a complete crash stack?

MimikFc7 commented 4 years ago

Can you provide a complete crash stack?

Hello, yes, i come back to home after a 8 hours and send.

MimikFc7 commented 4 years ago

2019-12-18 22:42:48.465149+0300 HomeAlone[998:190713] filter dps from lan 2019-12-18 22:42:48.465311+0300 HomeAlone[998:190713] -[__NSCFNumber length]: unrecognized selector sent to instance 0xb28e97f01270aa7c 2019-12-18 22:42:48.465563+0300 HomeAlone[998:190713] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0xb28e97f01270aa7c' *** First throw call stack: (0x185652a48 0x185379fa4 0x1855565a8 0x185656af4 0x185658a7c 0x192a540d0 0x192a54270 0x1bab8c0f4 0x1007cf9cc 0x10138df4c 0x1855ae288 0x1855ae2d0 0x1855ad630 0x1855ad2e8 0x18552959c 0x1855acc38 0x185909138 0x10096ec2c 0x1034957fc 0x103496bd8 0x1034a4c34 0x1855d05e4 0x1855cb5d8 0x1855caadc 0x18f550328 0x1896c5ae0 0x1008614fc 0x185454360) libc++abi.dylib: terminating with uncaught exception of type NSException

MimikFc7 commented 4 years ago

so i found where that trouble! in conversion type:

- (void)device:(TuyaSmartDevice *)device signal:(NSString *)signal

signal - it's a pointer, but in that pointer come NSNumber in Swift types conversion very strong.

i make a simple class and override that!

`- (void)device:(TuyaSmartDevice )device signal:(NSString )signal{

if(self.delegate != nil){

    NSNumber *cater = signal;
    [self.delegate device:device signal: [NSString stringWithFormat:@"%ld",[cater longValue]]];
}

}`

and it's work! please fix that!

TuyaRonbin commented 4 years ago

We will fix the errors in the next version. Sorry, I haven't tested swift before.

MimikFc7 commented 4 years ago

Yep, no problem, if you want, you can give me some codes for tested =)

Zabihullahkayani commented 3 years ago
        func getWifiSignalStrength() {
        self.device?.getWifiSignalStrength(success: {
            print("get wifi signal strength success")
        }, failure: { (error) in
            if let e = error {
                print("get wifi signal strength failure: \(e)")
            }
        })
    }

    // MARK: - TuyaSmartDeviceDelegate
    func device(_ device: TuyaSmartDevice!, signal: String!) {

    }

I am using this function from Tuya docs for iOS, my problem is my delegate method never call.