Creating a Coin Model based on JSON response from an API | SwiftUI Crypto App #3

  Рет қаралды 22,910

Swiftful Thinking

Swiftful Thinking

Күн бұрын

Пікірлер: 70
@qd3467
@qd3467 3 жыл бұрын
Nick, your teaching style suits my brain perfectly. Really enjoying the videos and learning loads. Thanks a bunch bro.
@josephdeweese2006
@josephdeweese2006 3 жыл бұрын
I agree. excellent
@siddharthkamaria
@siddharthkamaria Жыл бұрын
You can convert snake_case to camelCase by setting the JSONDecoder's property -- `decoder.keyDecodingStrategy = .convertFromSnakeCase` No need to write out all the CodingKeys manually. Happy coding :)
@hao-bz
@hao-bz Жыл бұрын
Exactly. I just implemented that in my viewmodel using .convertFromSnakeCase. worked like a charm !
@nevemra5
@nevemra5 Жыл бұрын
It’s not boring, it’s very interesting and informative. As always, thank you Nick!
@spradohak
@spradohak 2 жыл бұрын
Thank you for the great tutorial Nick, Just wanted to point out a trick regarding the Codingkeys , the "quicktype tool" you mentioned has an option called Exxplicit CodingKey values in codable types which is the third one in the options. just note that you need to disable the first option "Plain types only" and it will provide you with all the codingKeys for your properties. Hope this help.
@samarghourab5545
@samarghourab5545 2 жыл бұрын
The API is now under Products -> Crypto API -> Explore Docs
@harshavardhan5882
@harshavardhan5882 Жыл бұрын
Paid one right now
@hao-bz
@hao-bz Жыл бұрын
@@harshavardhan5882 you can still use the free version but is limited to 20-30 api calls per minute
@ReloadingBakchodi
@ReloadingBakchodi 3 ай бұрын
now it's paid one 😭
@karaokedeconstruction
@karaokedeconstruction 3 жыл бұрын
Awesome video, I was having trouble getting JSON converted to models in previous practice but this video clearly explained what to do.
@elaidzhashchukin7268
@elaidzhashchukin7268 Жыл бұрын
Thank you so much for doing this and all other videos !!! I liked the music btw :))
@CayenneHQ
@CayenneHQ 2 жыл бұрын
very helpful/instructive. Subbed w/ notifs on!
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Welcome Nico!
@literallyshane4306
@literallyshane4306 2 жыл бұрын
Another great video, I have been binging on these past few days, really helpful thank you! Quick question - why didn't you use the 'plain types' toggle on QuickType to generate the coding keys?
@RelaxMusic-eg9gq
@RelaxMusic-eg9gq 2 жыл бұрын
Absolutely not boring
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
😂😂🤕
@philippegden9826
@philippegden9826 3 жыл бұрын
Quick query - why didn't you use a mutating function to update currentHoldings? Thanks for this series - I'm learning everyday.
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Hey Philip, great question honestly. We could have used a mutating function here and it would have worked. However, we would have had to change the constants from "let" to "var". I prefer to keep Models with "let" constants so that the struct is considered an 'Immutable Struct'. This is a technique based on Uncle Bob's Clean Code which essentially makes all of the items inside the struct constants, so that they purposely can't be mutated. Then, if we want to update the struct, we will create a new Struct with updated data (as we are doing here). This helps to keep our code in sync, so we know that the Struct never gets mutated anywhere in the app, other than our update function. You can read some more about this here: medium.com/swift-programming/immutable-models-swift-29973170c08c
@joywu1
@joywu1 Жыл бұрын
I found at 10:21" change from class to struct, but didn't mention why. I guess is class will happen error CoinModel no init. but I don't know why
@MegaNerevar
@MegaNerevar Ай бұрын
I would recommend learning reference type vs value type. Class vs struct.
@harshavardhan5882
@harshavardhan5882 Жыл бұрын
Api is not Free right Now
@Khl8122
@Khl8122 3 жыл бұрын
Should you define a struct called something like CoinHolding which is composed of CoinModel and cuurentHoldingAmount: Double? (similar to sparlinelineIn7D) ? struct CoinHolding : Identifiable, Codable { //might need to do something to make CoinHolding conform to Identifiable let coinModel: CoinModel? let currentHoldingAmount: Double? }
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Hi Kevin, I don't think we need to make an entire struct for this variable. The computed variable I used should be efficient.
@ProgramJerol
@ProgramJerol 7 ай бұрын
The API is now paid sadly
@sampadaagarwal5675
@sampadaagarwal5675 2 ай бұрын
is there any ither api which i can use at this place
@ΑνδρέαςΓκόγκος-θ5σ
@ΑνδρέαςΓκόγκος-θ5σ 3 жыл бұрын
excellent video as always
@notorioustofu3482
@notorioustofu3482 Ай бұрын
For anyone following along and storing this in a Github repo, please remove your API key from the pasted comments before you push up your code
@MineRala-bn4ep
@MineRala-bn4ep 7 ай бұрын
Hello, holdings are coming to 0. Where do you set it? Where are you calling updateHolding(amount: )?
@光莒
@光莒 2 жыл бұрын
Hello, I'm very enjoy this video and this is super helpful for me, especially how to deal with complex json data~ I just wondering about what different if we used ''mutating func updateHolding(amount:Int){currentHolding = amount}' or the function 'updateHolding' in this video? thanks~ this series video is really wonderful!! I can't wait for more videos you make~~
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
It doesn’t make much of a difference in this situation. I explain it in detail here: kzbin.info/www/bejne/Y3uvlqGJibB4maM
@hashcat5721
@hashcat5721 2 жыл бұрын
8:14 It is better to use xCode -> Settings -> TextEditing -> Code folding ribbon
@rasheed1andrew
@rasheed1andrew 3 жыл бұрын
Within my project, I created 3 different models. 1 of the models had properties that was of type of another model. I also created properties that were of types of an array of another model. Everything worked fine but when it was time to access this models in the ui, I ran into problems with the ones in an array. Is there a way to access the models in the array or do I set up the array in the view model? Im definite it will work the other way around but I just wanted to know if there was a way to make the first setup work.
@CayenneHQ
@CayenneHQ 2 жыл бұрын
hey I wanted to code an app that sent a notification every time a wallet made a txn, do you have an idea of where I could start?
@jemmytech5474
@jemmytech5474 2 жыл бұрын
Sir when I click on execute, then I don’t see the response details- the json coinModel? Please help me
@NavdeepSingh-ut8md
@NavdeepSingh-ut8md 5 ай бұрын
Hi, nick can you provide alternate of this api, ? This is not free now.
@mhmtkrnlk
@mhmtkrnlk 2 жыл бұрын
Hey nick do you have any particular reason why you make CoinModel class but not a struct ?
@spradohak
@spradohak 2 жыл бұрын
he changed it to struct later on, I guess after the first two properties.
@lidders
@lidders Жыл бұрын
I was confused too but there’s a sneaky edit at 10:08 back to a struct
@jamshidbekhaydarov21
@jamshidbekhaydarov21 8 ай бұрын
❤❤❤
@张湘雄
@张湘雄 3 жыл бұрын
This video is great.
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Thanks you!
@muza700
@muza700 2 күн бұрын
instead of writing long enum CodingKeys: String, CodingKey { ... }, let decoder = JSONDecoder() decoder.keyDecodingStrategy = .convertFromSnakeCase that is it
@penguinwolf0125
@penguinwolf0125 2 жыл бұрын
Very good job! But I think you are mixing DTO, BO and VO objects. I know you do that for simplified code for newbies but they will learn the half of job. I like the way you teach, it just a comment.
@prashantsinghchauhan944
@prashantsinghchauhan944 2 жыл бұрын
Coin gecko api is no longer available:(
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
I believe they made the free api limited to 50/calls per minute. If you don’t refresh the canvas that often, you should still be fine to complete the course 😕
@prashantsinghchauhan944
@prashantsinghchauhan944 2 жыл бұрын
@@SwiftfulThinking thanks for your quick reply and it was helpful. Please create more content nick like fireball chat and verification, I would love to see you cover all that content 😍😍 Lots of love from 🇮🇳 🧡🙏🏼
@Nunny25
@Nunny25 3 жыл бұрын
ufff ..done
@ameliasaomarcos
@ameliasaomarcos 3 жыл бұрын
Nice
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Thanks vaisabehh 🥳
@knowledgeispower4953
@knowledgeispower4953 10 ай бұрын
😇
@nazargorevyi1697
@nazargorevyi1697 Жыл бұрын
Pls post a new API, current no longer free
@SwiftfulThinking
@SwiftfulThinking Жыл бұрын
I believe they still have a free API it is just rate limited now (www.coingecko.com/en/api/documentation). If you disable the SwiftUI previews, it will likely trigger less often.
@bobbletopia
@bobbletopia 6 ай бұрын
@@SwiftfulThinking Hi Nick. Thanks for all you do! Just wondering if there's an API you'd recommend, since CoinGecko seems to charge now?
@davehall6001
@davehall6001 2 жыл бұрын
CoinGecko is no long 100% free. It has 4 subscription structures. The starter is free but only allow 50calls/minute.
Design a row to display coins in a List | SwiftUI Crypto App #4
34:24
Swiftful Thinking
Рет қаралды 21 М.
Как Я Брата ОБМАНУЛ (смешное видео, прикол, юмор, поржать)
00:59
Creative Justice at the Checkout: Bananas and Eggs Showdown #shorts
00:18
Fabiosa Best Lifehacks
Рет қаралды 32 МЛН
Noodles Eating Challenge, So Magical! So Much Fun#Funnyfamily #Partygames #Funny
00:33
Reload the List with updated data from API | SwiftUI Crypto App #16
25:32
Swiftful Thinking
Рет қаралды 10 М.
SwiftData Basics in 15 minutes
15:18
CodeWithChris
Рет қаралды 51 М.
Download and display live market data from API | SwiftUI Crypto App #13
31:21
SwiftUI Drag and Drop with Transferable Custom Object
26:33
Sean Allen
Рет қаралды 24 М.
Swift API Calls for Beginners (Networking) - Async Await & JSON
25:35
SwiftUI API / JSON Tutorial with Async Await Example
9:52
Logan Koshenka
Рет қаралды 26 М.
Как Я Брата ОБМАНУЛ (смешное видео, прикол, юмор, поржать)
00:59