Learn Courses My Dashboard

Mark Moeykens' Journal

WEATHER APP

:spiral_calendar: Day 5

  • If I deleted a city and then added a new one, the index got messed up within the TabView. I reorder the index values after deleting a city. This helps with programmatic navigation.
  • Added progress view when first loading.
  • Added Settings view to switch between Fahrenheit and Celcius.
  • Added app icon.
  • Clean up code, added comments on where to find more info on the Combine parts in my book.
  • Tweaked UI, adjusted some padding, added background to hourly temps.

It’s done! Woo hoo!

2 Likes

Dude that design is smooth! I’m discovering just how tricky the design layouts can be just at the concept level. Yours looks great!

1 Like

Hey, thank you so much, Pagasi!

It looks better than the standard weather app heheh

1 Like

Thanks, Chris!

Your app looks great! Just to know how you did the data fetching with Swift Combine I bought you book :grinning: https://www.bigmountainstudio.com/combine/z7bnj :innocent: :drooling_face:

1 Like

Thank you for your support, Ralph! :green_heart: If you look in the code comments you’ll find references to specific parts of the book. Should get you pointed in the right direction to learn more in the book examples. :+1:

1 Like

Thank you for writing & publishing the book :blush: It‘s a great help to learn Combine!

1 Like

NBA STATS APP

So excited to do this again!
(My own reference to the challenge requirements.)

:spiral_calendar: Day 1

  • No coding, just research. Not much time today.
  • Setup account with sportsdata.io and started the free trial
  • Created an Xcode project in Xcode 13 beta 2. Could be taking a chance here. :smiley:
  • Found the API for scores
  • Found the API endpoint for scores by date (to get yesterday’s data)
  • Found the API endpoint for schedules (it’s on the same page, so that’s handy)

Team Images

  • Looks like there’s a different endpoint called “Teams (All)” to get all the team images and color palettes?
  • Could be interesting to use these colors in the UI.

Problems

  • Thinking about how to cache the team info so I only need to get it one time. Thinking Core Data is a good solution, but man, I haven’t used Core Data for anything at work so I never really used it. Not sure how much time I want to invest in learning it.
  • Anything I start to learn usually turns into a separate reference product which is very time-consuming. So first, I’m going to research quicker solutions and maybe have to learn Core Data after. This will be a good challenge for sure!

Core data is pretty easy to get up and running, Chris also has some awesome videos on this!!

2 Likes

hahaha… “…turns into a separate reference product…”
I can’t wait.

2 Likes

NBA STATS APP

:spiral_calendar: Day 2

Day of learning!

  • Watched Chris’s video (thanks for your suggestion too, @mikaelacaron)
  • Created a separate project to learn Core Data and play around with it
  • Tried my hardest NOT to start a book but I need to jot down some notes!

Apple Pages is a good place to keep notes.

So I started a new “notebook”. Which may look like a book but it’s not…yet.

(Seriously, I have too much to do right now so this really is just a notebook.)

2 Likes

I can see you fighting the urge to make another book. “The force is too powerful Luke…”

1 Like

NBA STATS APP

:spiral_calendar: Day 3

  • Got the app navigation layout. I’m going simple with a tab view.
  • Got the API working to get today and yesterday scores.
  • Then I was working on showing the future schedule and ran into a roadblock trying to decode the DateTime in the JSON. The error says:

Expected date string to be ISO8601-formatted.

I think Apple’s definition of iso needs a time zone. So I created a custom date format so I could decode with the help of this site:

extension DateFormatter {
    static let apiDateFormat: DateFormatter = {
        let formatter = DateFormatter()
        formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
        formatter.calendar = Calendar(identifier: .iso8601)
        formatter.timeZone = TimeZone(secondsFromGMT: 0)
        formatter.locale = Locale(identifier: "en_US_POSIX")
        return formatter
    }()
}

This date format matches the API’s date format.

Then I had to use this date format for the JSONDecoder() so I built a custom class and a static property:

class JsonDecoder {
    static var forApiDateFormat: JSONDecoder {
        get {
            let decoder = JSONDecoder()
            decoder.dateDecodingStrategy = .formatted(DateFormatter.apiDateFormat)
            return decoder
        }
    }
}

Besides that, I got:

  • The APIs working
  • Minimal data showing on all 3 screens

So that’s a pretty good win for me.

1 Like

NBA STATS APP

:spiral_calendar: Day 4

Man, I hate to say this but I think I’m going to have to throw in the towel on this challenge!
There is a lot of exploratory research I want to do to make this work such as:

  • Explore using the NSCache object
  • Explore persisting with a file
  • Explore persisting using Core Data

I think these topics could be a lot of fun to play with but then I look at other priorities on my plate right now:

  • Updating 4 books
  • House shopping
  • Family time
  • Recording videos

I’m overbooked!

So I didn’t make it very far. :disappointed:

My plan was to call the Teams (All) API endpoint and store all the team data locally. This API gets me this data:

struct TeamDO: Decodable, Identifiable {
    let id: Int
    var city = ""
    var name = ""
    var primaryColor = ""
    var secondaryColor = ""
    var tertiaryColor = ""
    var imageUrl = ""

    enum CodingKeys: String, CodingKey {
        case id = "TeamID"
        case city = "City"
        case name = "Name"
        case primaryColor = "PrimaryColor"
        case secondaryColor = "SecondaryColor"
        case tertiaryColor = "TertiaryColor"
        case imageUrl = "WikipediaLogoUrl"
    }
}

So I wanted to persist them and then when I got score info, I could access this local data and get the full team names, logos, colors.

Well, good luck to everyone else on the challenge!