wvteijlingen / Spine

A Swift library for working with JSON:API APIs. It supports mapping to custom model classes, fetching, advanced querying, linking and persisting.
MIT License
264 stars 109 forks source link

Update syntax to swift 3 #108

Closed waritsan closed 7 years ago

waritsan commented 7 years ago

Xcode 8 requires me to make theses type casting changes in order to build successfully.

wvteijlingen commented 7 years ago

Hm, weird. This does't show up for me. Can you inspect what the return type of the .URL method of SwiftyJSON is? It should already be a URL.

waritsan commented 7 years ago

In my case it returns an NSURL. I'm using this SwiftyJSON https://github.com/IBM-Swift/SwiftyJSON.git. Which version do you use?

//MARK: - URL
extension JSON {

    //Optional URL
    public var URL: NSURL? {
        get {
            switch self.type {
            case .string:
                guard let encodedString_ = self.rawString.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed) else {
                    return nil
                }
                return NSURL(string: encodedString_)

            default:
                return nil
            }
        }
        set {
#if os(Linux)
            self.object = newValue?.absoluteString._bridgeToObjectiveC()
#else
            self.object = newValue?.absoluteString
#endif
        }
    }
}
waritsan commented 7 years ago

Oh I see in Cartfile you have github "appsailor/SwiftyJSON" "swift3". Let me try that.

waritsan commented 7 years ago

Pointing to appsailor/SwiftyJSON works for me now