strongloop-community / loopback-sdk-ios

iOS Client SDK for the LoopBack framework.
Other
76 stars 39 forks source link

Swift 3.0 #120

Open agfa555 opened 7 years ago

agfa555 commented 7 years ago

SDK is throwing millions of errors in Swift 3.0 Anyone has it working?

yellowred commented 7 years ago

I am struggling with "Cannot convert value of type '(NSError!) -> Void' to expected argument type 'SLFailureBlock!'". This code sipped was working for Swift 2 and it seems there is a problem with Swift 3:

financial.saveWithSuccess(
    {() -> Void in
        NSLog("Financial saved")
    }, failure: { (error: NSError!) -> Void in
        // failure block
    }
)

I am not an expert in Loopback iOS SDK though. It would be great if some one can prove this SDK working for Swift v3.

agfa555 commented 7 years ago

Hi @yellowred,

Try changing to:

financial .save(success: { () -> Void in 
NSLog("Financial saved")
}, failure: { (error: Error?) -> Void in 
// failure block
})

It's so sad this SDK is not updated for more than a year. I think we're dropping from Loopback soon. Hope it works.

superkhau commented 7 years ago

@bajtos ^

bajtos commented 7 years ago

Hello, I am afraid Swift 3 support in the iOS SDK is not a priority for us right now. Would you mind contributing the necessary changes yourself?

agfa555 commented 7 years ago

I have made so many changes already that I don't think it might suit other people. Support for Swift 3 is nothing more than a few improvements to the Objective-C code. Here's a very good article on what to do and not to do: https://realm.io/news/altconf-conrad-kramer-writing-iOS-sdk/