Download coins using a View Model and Data Service class | SwiftUI Crypto App #6

  Рет қаралды 17,921

Swiftful Thinking

Swiftful Thinking

Күн бұрын

Пікірлер: 72
@mica00ela
@mica00ela 5 ай бұрын
I appreciate how you actually think out loud with real comments about what has to be decided (eg using the cancellables set vs single cancellable publisher) because it makes it so much easier to follow your reasoning, remember the points and understand what's going on. Too many tutorials imo go through the motions in an automated way that makes them boring, vague and unclear. Thanks !!
@nevemra5
@nevemra5 Жыл бұрын
Thank you for explaining several times what and why we need. It helps a lot to understand!
@KimbrellBrad
@KimbrellBrad 3 жыл бұрын
Just like Magic! Brutal seeing the drop in BTC over the past month but we are learning! Can't wait to go back and convert all of my API projects to use Combine. Actually much more readable IMO. Thanks for the excellent course!
@williamwildsmith5162
@williamwildsmith5162 2 жыл бұрын
Invest in real things. Crypto is one big piss-take; same as NFTs.
@kmitina
@kmitina 2 жыл бұрын
I love this course! Your explanations are absolutely brilliant! Thanks for you great job! I appreciate it so much!
@irfanrizvi161
@irfanrizvi161 3 жыл бұрын
Was able to follow along, but I am not very confident if I've understood the concept of cancellable. I gotto work on that one. Great video, excited to see the complete app. Many Thanks.
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Glad you were able to follow along! You can think of Cancellable just like an email subscription... You sign up for an email subscription and they will keep sending you emails. If you "unsubscribe", then you cancel the subscription and they won't send you any more. This is the same thing!
@4141ozan
@4141ozan 3 жыл бұрын
Your explanations and code advices very awesome. Thanks a lot man!
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Thanks Ozan!!
@BrettHoTep
@BrettHoTep 2 жыл бұрын
These videos are excellent. Informative, and applicable in real world applications. Thanks so much for putting these together.
@julianm080808
@julianm080808 9 ай бұрын
Hey Nick thanks once again for this marvelous videos, you are fantastic buddy.
@DaveJacobseniOS
@DaveJacobseniOS 3 жыл бұрын
Amazing. This was my very first time using combine and you explained it so well. Determined to make it to the end🤓
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
😎🤓
@dun198
@dun198 2 жыл бұрын
Thanks for this amazing course! So far, all your videos have been super helpful and I really learn a lot from them! Instead of Combine I'm trying to use async/await throughout the rest of this course. This seems like a nice challenge and a good opportunity to practice both. For now everything went smoothly.
@oldschool84
@oldschool84 7 ай бұрын
Hey man, I also want to do it via Async/Await. Can you write me a piece of code for that and how you solved it? Thank you
@cruiseqe2
@cruiseqe2 3 жыл бұрын
Worked first time. Awesome to see some 'real' 'live' results - but no idea of what the coins are! Looks cool though, and lots of great tuition along the way.
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Fewf! I was a little nervous some people would get stuck here. I'm very happy you saw the data on the first that. That's awesome! It's almost better if you don't know about the coins, because then you can focus on the data and data structure. Downloading, decoding, and displaying is the same logic for any type of data!
@vladyslavsushko1967
@vladyslavsushko1967 11 ай бұрын
Best! It's clean and smart! Thank you
@vladyslavsushko1967
@vladyslavsushko1967 11 ай бұрын
it worked on the first try
@tomqin3685
@tomqin3685 3 жыл бұрын
Great job!
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Did you fix that error message?
@tomqin3685
@tomqin3685 3 жыл бұрын
@@SwiftfulThinking Ohhh, Yes ! I found your GitHub and compare to my code. I make a mistake with my spelling😅. Thanks again!
@Benbbr
@Benbbr 3 жыл бұрын
Seeing the prices per Coin on the end showing you've made the videos a while back already. *sigh Step by step getting there. I am doing a EUR list, but see the challenge of getting the device adapt to the right region and coins for a production app. Much to learn. Eager to do so.
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Oh haha that's a nice addition! There should be ways to easily get the current user's locale/currency if you need to. .... and yes, the prices were a lot higher when I was making that haha. HODL!
@josephdeweese2006
@josephdeweese2006 Жыл бұрын
just saw this as well...the orange pill shall return
@AZMerf
@AZMerf 3 жыл бұрын
Very nice. Totally confused LOL but I'll walk through it a couple of times. Mine didn't work the first time but I ran the simulator and got the error that the data wasn't formatted correctly. Turns out, one line in the model wasn't correct. I used an Int instead of a Double on the line with totalVolume, high24H, low24H.
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Oh yea I think the QuickType website might have done that accidentally. All of the numbers in the Model should be Doubles. Glad it's working now!
@Tessa_Pink
@Tessa_Pink Жыл бұрын
“The data couldn’t be read because it isn’t in the correct format.” Excuse me, is this issue caused by an error during decoding?
@briturner11
@briturner11 2 жыл бұрын
Why did you dispatch onto the main queue before decoding? presumably that could still all happen on the background queue and only dispatch to main to update the property which would trigger the UI events
@matthew78uk
@matthew78uk 2 жыл бұрын
I was just about to ask the same question, anybody knows the answer to that?
@onurhaneth
@onurhaneth Жыл бұрын
Hey ! I have completed till the end also I got the coin list successfuly yesterday. But today I just opened xcode and tried to run simulator. Now there is no data feed anymore, what can be the issue ? I double check and nothing changed by mistake
@hargunrana
@hargunrana 3 жыл бұрын
for some reason the homeview list comes out to be empty... help out
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Maybe you missed something? You can join our Discord if you want some help with your code: discord.gg/vhKKyYTGDb
@PratyushMishra7
@PratyushMishra7 Жыл бұрын
The data couldn’t be read because it isn’t in the correct format. i am getting this error how to fix
@hakobghlijyan
@hakobghlijyan Жыл бұрын
And please, how work is local json API... I make json this all data is this site... How func combine use this local json version?
@mohd.rajeen4256
@mohd.rajeen4256 Жыл бұрын
hey It is giving this error message " The operation couldn’t be completed. (NSURLErrorDomain error -1011.) ". Not sure what does it refer to. Need help, I'm stuck!
@amadzarak7746
@amadzarak7746 5 ай бұрын
Hey friends, if ur getting the "cannot complete operation error" it might be worth changing the error print statement from error.localizedDescription to just error whilst debugging. I had an issue with my coin model, as the api was returning some null values. so I had to change some of the values from Double to optional Doubles
@Nunny25
@Nunny25 3 жыл бұрын
Perfect, thanks. Some issues - after runing app in simulator and iPhone I have some issues. On simulator, there is different sign then "$" and on my phone, where is Czech language, I can see instead of $ CZK. It is not correct, because I see price in USD. Also letters "CZK" are somtimes on second row and it not looks good. Even if I uncoment currency symbol, currence code in Double extension. Any idea?
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
I'm not too familiar with the currencies, but the formatter should support all currencies. I think you can also alter the API to not use the USD prices if needed
@Nunny25
@Nunny25 3 жыл бұрын
@@SwiftfulThinking Hi, I think, that currency should be the same as currencies get from URL (USD, EUR) and not from phone settings. This option should be in application settings and let users choose prefered currency.
@jamshidbekhaydarov21
@jamshidbekhaydarov21 8 ай бұрын
❤❤❤
@hakobghlijyan
@hakobghlijyan Жыл бұрын
this api not free now... don't work
@cinquain0
@cinquain0 3 жыл бұрын
I got a question… how come the coin data service didn’t conform to observable object like the video model did, they are both publishers no?
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
You honestly have the best questions haha. We needed the ViewModel to conform to ObservableObject because we are observing directly from a View. This is why we can use @StateObject, @ObservedObject, or @EnvironmentObject on the ViewModels. We don't need these property wrappers for the data service since we are not referencing it from the View!
@cinquain0
@cinquain0 3 жыл бұрын
@@SwiftfulThinking ah! Got it. Thanks for answering. Loved your course on Udemy btw. Still waiting for one on push notifications using fire base cloud functions.
@TheSpiralnotizblock
@TheSpiralnotizblock 2 жыл бұрын
Don't know if I have only this problem, but the gecko API is soooooooooooo slow
@gregohb
@gregohb 3 жыл бұрын
I was able to get the data ... but I had to ignore the URL in your sample project and re-create it from the gecko website from scratch and then it works fine.
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Hey G. It sounds like the JSON Decoder might be failing. I would check the CoinModel and see if you mistyped something. You can try making all variables optional and see if it decodes.. and then see which variables are not pulling through.
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Oh that's strange. I'll have to take a look. Glad it's working now!
@hargunrana
@hargunrana 3 жыл бұрын
hey i did everything correctly but could see anything on the list... tried to get a new url as well... help out
@Rock_concerts
@Rock_concerts Жыл бұрын
(NSURLErrorDomain error -1011.) what is the error?
@alvaroquiroga3373
@alvaroquiroga3373 Жыл бұрын
Hi, i have the same error, did you fix it?
@hakobghlijyan
@hakobghlijyan Жыл бұрын
And me... It's many requests... Problems.
@kenedy2801
@kenedy2801 Жыл бұрын
@@alvaroquiroga3373 check response in tryMap must response.statusCode >= 200 && response.statusCoe < 300
@kenedy2801
@kenedy2801 Жыл бұрын
@@hakobghlijyan check response in tryMap must response.statusCode >= 200 && response.statusCoe < 300
@V_0six
@V_0six 10 ай бұрын
They have changed the API, you need to make an account and get a demo API Key. Then change your URL to include "?x_cg_demo_api_key=YOUR_API_KEY" at the end. I also had to remove "priceChangePercentage24HInCurrency" from my model to get it to work.
@TarunReddy_RM
@TarunReddy_RM 3 жыл бұрын
Hey nick, Im pretty sure i did everything right and I know it cant be the model because Ive even imported your model file into my project as a substitute. I rebuilt the project twice from scratch and got to the same result which is my list being empty. The error being printed to the debug console says "....failed to log metrics. This operation couldn't be completed. (NSURLErrorDomain error -1011)" Any idea on what this means?
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Hi Tarum, it looks like a URL error. Did you type the URL correctly? Make sure you include S in HTTPS
@TarunReddy_RM
@TarunReddy_RM 3 жыл бұрын
@@SwiftfulThinking Yes, thats the strange thing Ive copied and pasted your url, refetched the url from coin gecko multiple times the list is still just blank. I made sure to add the "s". Im not getting any errors and the project is still building but no list data is being shown, just the header and the columns
@TarunReddy_RM
@TarunReddy_RM 3 жыл бұрын
@@SwiftfulThinking Im so dumb omg the status code range was from 300 to 300 lmao
@aybarsacar9375
@aybarsacar9375 2 жыл бұрын
Thanks for this amazing content Nick! I am curios how we could communicate a loading state to our view. For example, in an android project, i would emit states from a coroutine and the initial state would be a loading state and the final state would either be a success state with data in it or an error state with a user friendly message in it Any ideas how i can implement something similar in swift for ios? Cheers!
@anzzz119
@anzzz119 3 жыл бұрын
the video is and your courses are fucking awesome, but I miss how you find everything, like reading thru documentation os if you google something that you don't know how it works. It will be cool for the next course that you do the whole process, of doing the app, how you prepare for it , how yo look for the thing you don't know how it works etc
@vazzhh
@vazzhh 5 ай бұрын
Could it be that I'm too stupid to be able to understand? Because everyone says it's fascinating and I still don't understand many things ☹☹
@mystride
@mystride 2 жыл бұрын
Q1: Is there a more modern approach that does not use Combine to having multiple VM's w/ @Published var's subscribe to a central data store w/ @Published var's. Q2: Would it be wise (and how so) to initialize the data services/stores in a singleton pattern upstream from the first VM that needs to access that data? This way the first VM does not have to worry about the data services/stores being instantiated and the data services/stores can get a jump on hydrating themselves.
@bfriendjr
@bfriendjr 3 жыл бұрын
I must say, I can not believe the quality of this course. I have followed many courses, especially on Udemy and I must say, this course is probably one of the best. I completed this course without any issues and now I would like to build onto what I have done and I am hoping you could point me in the right direction. For example, I would like to chain api calls so I can get the top 1000 coins via api call for page 1, page 2, page3 and so on. I think this can be done via Combine Publishers.zip or Flatmap, but I am not quite certain how to implement this. I would greatly appreciate some assistance.
@josephdeweese2006
@josephdeweese2006 Жыл бұрын
wow....bitcoin was 58K😄
Add a reusable Networking layer | SwiftUI Crypto App #7
20:55
Swiftful Thinking
Рет қаралды 17 М.
ТВОИ РОДИТЕЛИ И ЧЕЛОВЕК ПАУК 😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 7 МЛН
Why no RONALDO?! 🤔⚽️
00:28
Celine Dept
Рет қаралды 97 МЛН
Deadpool family by Tsuriki Show
00:12
Tsuriki Show
Рет қаралды 3,5 МЛН
Implement a custom and reusable search bar | SwiftUI Crypto App #10
18:21
Swiftful Thinking
Рет қаралды 19 М.
Add a dynamic List to display downloaded coins | SwiftUI Crypto App #5
17:36
Add a Settings screen using a List with Sections | SwiftUI Crypto App #23
24:36
Xcode 15: Better Logging / Debugging Support
8:02
iOS Academy
Рет қаралды 11 М.
Download and display live market data from API | SwiftUI Crypto App #13
31:21
The Most Misused Design Pattern in Swift
5:56
Sean Allen
Рет қаралды 18 М.
Building a Mobile App in 2024: The BEST Technologies
13:31
Dan Ilies
Рет қаралды 103 М.
ТВОИ РОДИТЕЛИ И ЧЕЛОВЕК ПАУК 😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 7 МЛН