Chapter 12 - Starter Project

The starter project no longer builds with SwiftyJSON 4.
JSON(data:) now throws and it’s not handled by starter project in ApiController.swift line 102.

I’ve changed it to this (haven’t tested but should be okay I guess. Assuming it never throws…):

return session.rx.data(request: request)
      .map {
        do {
          return try JSON(data: $0)
        } catch {
          return JSON()
        }
    }

I feel like Chapter 12 overall still needs updates. There are also some other issue pointed out by other posts in forums.
Just a suggestion :]

3 Likes

Just wanna add that Chapter 13’s starter project seems to be up to date. (Spoiler, it’s still the Wundercast app.)
The return block is like this:

return session.rx.data(request: request).map { try JSON(data: $0) }
3 Likes

I found this as well and changed it as you did.

Just faced this issue as well! Thanks for posting a workaround!

This topic was automatically closed after 166 days. New replies are no longer allowed.