SwiftUI Tutorial: How to make a API call, fetch JSON, and structure you networking layer with MVVM

preview_player
Показать описание
In this tutorial, we are going to fetch JSON data from an API and show it in a list view in SwiftUI. I will discuss how I structure my code base with MVVM (Model - View Model - View). Also I am including an extra layer for the networking logic because it helps make my code more reusable and write unit tests. You will also learn about error handling with URLSession and how to show error information to the user.

😻 The example API is the cat API.

Overview
00:00 Introduction
02:52 project organisation with MVVM
15:05 error handling, custom error type
19:03 Separate networking layer and error handling
28:44 loading view
29:48 error view
33:08 breed list views with AsyncImage
41:18 searchable view modifier to search by breed name
43:11 cat breed detail view
47:11 unit tests, mock service and dependency injection
54:29 Wrap up

🤩 Learn more

If you liked what you learned and you want to see more, check out one of my courses!
👩🏻‍💻 Combine course

#SwiftUI #networking #JSONParsing #API
Рекомендации по теме
Комментарии
Автор

Thank you, Karin! This was a tremendously useful tutorial, even a couple years later.
It would be great to see an updated version that uses async/await.

StephenRouse-ttpr
Автор

Thank you, thank you, thank you. I was unable to put a structure to making properly designed project containing API calls. This was a savior.

ekadam
Автор

I like the way you teach. First you're doing it then you are reforming the code. Thanks Karin.

burakcankurtarr
Автор

It's amazing how many skills and how many aspects are covered in one tutorial under 1 hour comparing with other ones that show just one thing in more than 1 hour. Well done!

milanfdl
Автор

Great video. I think you're my favorite Swift teacher. This is the kinda stuff pro-coders wanna watch. It's "for beginners", but it goes so much more in-depth while making sense, than other Swift Youtubers. Glad you're making videos. Greatly appreciate the unit test chapters too.

guitaripod
Автор

Absolutely the best ios tutorials on youtube, look forward to your next course

rDivaDuck
Автор

All your videos are very helpful, I have never seen a detailed tutorial like yours. Thank you.

mochamadnurkhayalkadafi
Автор

Informative, clear, quality...

Positive feedback:
As an android developer with couple of years of experience, I think this is the most straight-forward video for people like me who is interested in learning how to do things on iOS that you do on Android.
I loved how it is easy to understand (kind of beginner level) but also cares about industry level stuff such as architecture, testability (using protocols)
I literally can't wait to discover your other videos.

Neutral feedback:
I would like to hear a bit information about iOS specific stuff while you're using them. For example, in a part you say "we should probably use guard let" but I don't know the difference. And I know it's not in the context of this video, that's why I mention this as a neutral feedback and not as a negative one. It would just be more delightful for people like me.

But overall, great content, Karin. Thank you

denizbutandroid
Автор

Great video, exactly what I'm looking for. Step by step instruction of how to build a real world production ready list to detail app, with unit tests. This video doesn't cover basics of Swift and SwiftUI so learn those knowledge before watching this. Really appreciate your effort!

daixiangli
Автор

Thank you so much for the detailed explanation. Helped me understand a lot as a beginner in Swift UI.

shrinidhishetty
Автор

Fantastic tutorial! I learned so much in an hour! Thank you! ❤

teaberry
Автор

Best tutorial I've found on youtube, thank you!

ruzev
Автор

Lots of great thinking, here, for architecture, testing, etc. Thank you!

stevebarron
Автор

So happy I found your channel, most of the channels present simple stuff, that are nice. However once the project grows it gets harder to separate the stuff correctly and most of the videos just leave it ...

slavihinkov
Автор

Thanks from Japan.
Your video is very useful to me.
Thank you very much.

Sorry, my poor English

本名出さない設定
Автор

This is exactly what I was looking for making a robust networking layer. Thank you so much for this.

MayurPatilishere
Автор

Thank you for the great video. It was pretty straight forward and easy to follow.

superusr
Автор

Thank You!!! Its very Useful video !!!

lusinekhachatryan
Автор

Simple and great explanation! Thank you for your work!
GO ON!

ShooMPozitiV
Автор

Hello Karin! Very easy and super tutorial. Thanks

MrLawaghar