validUserTokenSync()

I need to check that the user is still logged in properly, but the example in the docs for Swift is incorrect.

I have setStayLoggedIn set to true. Using the code results in an error as .try doesn’t exist. However replacing it with .tryblock crashes the program after a while sitting frozen.

Error;

unrecognized selector sent to instance 0x7ff6b942f6d0

Could not cast value of type ‘NSException’ (0x10a945358) to ‘Fault’ (0x106bb5740).

func validUserTokenSync() {     Types.try({ () -> Void in       var result = self.backendless.userService.isValidUserToken() //as NSNumber       println("isValidUserToken (SYNC): \(result.boolValue)")       },       catch: { (exception) -> Void in         println("Server reported an error (SYNC): \(exception as Fault)")       }     ) }  

My code…









func validUserTokenSync()  -> Bool {

        var valid: Bool = false

        MMProgressHUD.showWithStatus("Connecting")

        Types.tryblock({ () -> Void in

            

            var result = self.backendless.userService.isValidUserToken()

            debugPrint("isValidUserToken (SYNC): \(result.boolValue)")

            valid = result.boolValue

            MMProgressHUD.dismiss()

            },

                       catchblock: { (exception) -> Void in

                        debugPrint("Server reported an error (SYNC): \(exception as! Fault)")

                        MMProgressHUD.dismissWithError("Please try later", title: "Server Error!", afterDelay: 4)

        })

        return valid

    }

Hi!

I tried isValidUserToken() with latest ios sdk https://github.com/Backendless/iOS-Samples and it works without errors. Could you try validUserTokenSync() from these swift samples?https://github.com/Backendless/iOS-Samples/tree/master/samples/swift

Updated pod to 3.0.14 from 3.0.10

Copied in the function from GIT, but still get the same result.
Strangely Xcode is lining up the function in an odd way. (attached)

Screen Shot 2016-04-12 at 11.05.29.png

created internal ticket BKNDLSS-12329

Please update the latest CocoaPods (3.0.20 release)