Codable, Decodable, and Encodable in Swift | Continued Learning #21

  Переглядів 18,944

Swiftful Thinking

Swiftful Thinking

3 роки тому

Codable is one of the most powerful protocols in Swift! We use this to "decode" and "encode" data in our application. This is especially useful for downloading data from the internet, because when we download data it will come as a foreign data type (usually JSON data). We then use Codable to transform (or "decode") the JSON data into a data type that we have in our iOS application. In this video we will first learn how Codable is actually using Decodable and Encodable protocols behind the scenes to transform the data and then we will learn how to implement Codable itself!
Next video: • Download JSON from API...
Last video: • How to use escaping cl...

КОМЕНТАРІ: 91
@frederickjavalera558
@frederickjavalera558 2 роки тому
I'm glad that you took the approach that you did to first build up our "behind the scenes" insight by going through Decodable, then Encodable, and then, finally, Codable. Great teaching approach.
@tibettenballs4962
@tibettenballs4962 Рік тому
except if he forces you to do other things...
@kjlee7826
@kjlee7826 2 роки тому
Thank you for your effort and kindness to explain things even under the hood! Now I finally understood the differences among decodable, encodable, and coddle!!!!!
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
🥳 Thanks KJ!!
@prashantsinghchauhan944
@prashantsinghchauhan944 2 роки тому
I have got an internship cuz of your course out here. Lots of appreciation from India. 🔥
@kriendeau67
@kriendeau67 2 роки тому
Nick you just totally blew me away! I cannot believe codable is so powerful. Eliminating all that code I was like, this isn't going to work, but it does! Thank you for your clear concise teaching methods. Ive been following every video since beginner bootcamp and you have taught me so very much!
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
Haha thanks for watching! Yea, Codable is super powerful :)
@nikiforzh
@nikiforzh Місяць тому
Daaaaaaaamnn! Bro, the end of this video is sooo unpredictable, I thought it would be so difficult that I would spend a lot of time on it. Now I know how it works inside, and I can use it! You're a genius! Thank u soo much, love this channel
@coffeeCatPeanutDust
@coffeeCatPeanutDust 2 роки тому
Awesome video. I'm surprised I've got this far. For what I'm used to, this is already 'next level' but because it's so well taught I don't feel lost.
@MrTalhakhan01
@MrTalhakhan01 2 роки тому
Man, awesome awesome awesome video. I can't stress it enough.. you just explained the concept in most deserving way. Thank you Please dont stop teaching
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
Welcome to my channel and thank you Talha! 🥳
@vladimirmoor
@vladimirmoor 2 роки тому
The puzzle of JSON, Dictionary, Codable, CodingKeys is completed in my head. Great job!
@douglasrutledge1325
@douglasrutledge1325 2 роки тому
It's all there until I go to sleep, an all that code drains out on my pillow, guuuur!
@KNOWLEDGEINFINITY_YOUTUBE
@KNOWLEDGEINFINITY_YOUTUBE 2 роки тому
This guy is a legend... WOW, what an explanation!!!
@pawelpow
@pawelpow 2 роки тому
Thank you again! You have the best structured and systematic SwiftUI course out there! It’s an honour to be watching these videos!
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
Glad you're enjoying it :)
@jamesleetrigg
@jamesleetrigg 7 місяців тому
I am a lead iOS developer with lots of experience in Swift still, I always find something new and interesting in your videos. Just because I know something doesn’t mean I know, know something. Understanding something is an order of magnitude, better than knowing something. Thanks for your great content.
@paulraggett7837
@paulraggett7837 3 роки тому
I really enjoyed the journey in this video. Great work Nick.
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
Thanks again Paul. It's incredible how powerful Codable is haha
@BenjaminEggerstedt
@BenjaminEggerstedt 2 роки тому
Thanks for going through all that happens in the background, it makes the magic so much more enjoyable! I really enjoy your video series, thank you!
@30guarino
@30guarino 3 роки тому
Great job explaining all of this!! At first I was like WTH is going on here ...then I was like OH! I got it now
@SwiftfulThinking
@SwiftfulThinking 3 роки тому
Hahaha thanks David. Yea I know we did a lot of extra coding here but otherwise I would have added "Codable" and no one would understand what was actually happening lol
@oliverpark6116
@oliverpark6116 2 роки тому
I was doing the Swift UI tutorials in Apple Website, but I could not understand the Foundation part, however, this channel let me to understand quick and easy about Codable.
@simply6162
@simply6162 Рік тому
Yes this guy is god when it comes to how education should be. This sets a new standard for teaching and it’s hard for me to go back to the old teachings
@Natena
@Natena 8 місяців тому
This is Crazy how you teach Codable in 30 min, while i ve spent weeks to understand it.
@stefanlindholm3284
@stefanlindholm3284 2 роки тому
Thank you Nick for another great video!
@geomichelon
@geomichelon Рік тому
great explanation . I m working with ios since 2013 , i came from objective C , and i never seen a good tutorial like yours. Amazing!!! Greetings from Brazil !!! 🙂
@kotya7892
@kotya7892 8 місяців тому
The end is amazing! 🤩
@meimerlin7141
@meimerlin7141 6 місяців тому
Thank you so much for spending so much time to explain the basic and root logic within the struct. The important thing is to the beginner developer, like me, who could really write the code confidently after learning your course!!!
@spradohak
@spradohak Рік тому
Brilliant explanation Nick, Thank you a lot
@franklemur5518
@franklemur5518 Рік тому
So well explained - Thx I have been struggling with Decode protocol. Not no.
@curt8806
@curt8806 2 роки тому
The best channel on UKposts for SwiftUI
@Watashi10
@Watashi10 8 місяців тому
Wow, such a great and clear video on Codable. Nice unexpected twist at the end :)
@magedmohmed4403
@magedmohmed4403 Рік тому
Thank you Nick , your explanation is very useful for us 🥰
@mingzhongdai2870
@mingzhongdai2870 9 місяців тому
This is awesome!!
@pakaponwiwat2405
@pakaponwiwat2405 Рік тому
Thank you very much, Mr. Nick!!
@NickGo
@NickGo Рік тому
Thank you so much for your way of explaining this! What a saver!
@user-vf2yy9gq3k
@user-vf2yy9gq3k 9 місяців тому
Thank you so much!
@asfandiyar5829
@asfandiyar5829 7 місяців тому
Mind-blowing. Thanks
@sureshbabu-qp4zr
@sureshbabu-qp4zr 9 місяців тому
Really helpful
@kdtechniquesofficial6153
@kdtechniquesofficial6153 2 роки тому
Thanks for all your effort. ❤️❤️
@tarun_reddy
@tarun_reddy 2 роки тому
Once again Nick is clutch asf
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
Tarun buddy what's up man. Haven't heard from you in a few weeks, glad you're still here 🥳
@olepetersen4460
@olepetersen4460 2 роки тому
You are a true master - thanks again - again!
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
Lol Ole! Thanks for watching :)
@kdtechniquesofficial6153
@kdtechniquesofficial6153 2 роки тому
You”re very welcome bro....❤️
@nevemra5
@nevemra5 11 місяців тому
Oh! Soooo awesome… thank you
@mamazur
@mamazur 2 роки тому
Nick you are legend!
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
Haha thanks Ma 🥲
@AZMerf
@AZMerf 3 роки тому
Brilliant! Keep going!
@SwiftfulThinking
@SwiftfulThinking 3 роки тому
Thank you! Will do Merrill!
@rajatpandya4930
@rajatpandya4930 2 роки тому
Thank you so much for such a easy videos :) :)
@bestpricesignsprinting3300
@bestpricesignsprinting3300 Рік тому
Amazing!!!!
@calvinkim6615
@calvinkim6615 Рік тому
Thank you very very much. 🙂
@mishapushka708
@mishapushka708 2 роки тому
It's cool Codable😊 Thanks!
@uzochukwu1556
@uzochukwu1556 Місяць тому
Awesome!
@andrejkling3886
@andrejkling3886 3 роки тому
Thank you...
@23mmvideo
@23mmvideo Місяць тому
Codable is so cool!
@user-ry6ix2mr8y
@user-ry6ix2mr8y 3 роки тому
Thank you Nick, cool
@SwiftfulThinking
@SwiftfulThinking 3 роки тому
Thanks again for watching Максим!
@gucp
@gucp 11 місяців тому
I just wanted to say thank you to Nick for making all these contents and making them available to anyone. The concepts are explained clearly and in a easy-to-understand way.
@SwiftfulThinking
@SwiftfulThinking 11 місяців тому
Thanks!! 🤙
@sols.2525
@sols.2525 3 роки тому
Incredible!
@SwiftfulThinking
@SwiftfulThinking 3 роки тому
Thanks Scott! I know there was a lot of code in this video haha
@pasha7324
@pasha7324 10 місяців тому
This video is gold 🥇
@aaronz8952
@aaronz8952 5 місяців тому
you done a good video!!
@douglasrutledge1325
@douglasrutledge1325 2 роки тому
that is some crazy Magic!
@dodilodi1278
@dodilodi1278 Рік тому
FYI: if you create CodingKeys first, then init(from decoder) and encode() will be automatically written you start typing it.
@SwiftfulThinking
@SwiftfulThinking Рік тому
You’re right! This was recently added to Swift.. when I made this video we still had to type it all manually 🥵
@peterellison8306
@peterellison8306 2 роки тому
Another fabulous video. (Coffee coming!). But how do you conform to Codable if you are using a Core Data Entity as your data model (for data persistence purposes)?
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
Great question... well we use Codable to decode data from a foreign type (often JSON) into some sort of usable Model in our app. When we fetch items from CoreData, they are already Entities, which are Models that the app already understands. In short, we don't need to do any decoding for CoreData Entities. Some developers will still transform Core Data Entities into more universal data types, but you still wouldn't need to encode or decode.
@Nunny25
@Nunny25 2 роки тому
Hi Nick, amazing ...
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
Hi again Charlie!
@hawkeye6614
@hawkeye6614 3 місяці тому
🎯 Key Takeaways for quick navigation: 00:34 📚 *Understanding the Codable protocol in Swift involves delving into decoding and encoding data for app usage.* 01:45 🌐 *Codable facilitates decoding JSON data from the internet into usable app data and encoding app data into JSON for internet transmission.* 03:08 🛠️ *Swift's Codable protocol automates encoding and decoding processes, simplifying data handling in apps.* 07:50 📤 *Simulating data download with mock JSON illustrates preparation for real internet data handling in Swift apps.* 18:56 🔄 *Codable protocol streamlines data conversion tasks, especially useful for managing complex data models in Swift applications.* 20:39 🔑 *Conforming to `Decodable` allows initializing a model from data, decoding it into the model.* 22:56 🛠️ *Customizing `CodingKeys` enables mapping between model properties and data keys during decoding.* 25:17 🧩 *Efficient decoding with `JSONDecoder` simplifies data processing and model initialization.* 28:18 📤 *Conforming to `Encodable` allows converting a model into JSON data.* 32:34 🌟 *`Codable` combines `Decodable` and `Encodable`, automating data decoding and encoding processes.*
@ecptavares
@ecptavares Рік тому
Im following along with your code but using a json file I have with over 3.500 records but after testing a series of possibilites my code is not working due to the line ...let dictionary = localData as? [String:Any]. if I put this two lets in a separated ifs the else statement of the second gets executed so I assumed the error is on the second if right.What am I missing?thank you.
@kdtechniquesofficial6153
@kdtechniquesofficial6153 2 роки тому
according to spacebar sounds u have a magic keyboard....😜
@sattorjabborov2728
@sattorjabborov2728 Рік тому
💥💥💥
@102_roblox
@102_roblox Місяць тому
👏
@paulmax9155
@paulmax9155 Рік тому
It's bad practice not to catch errors, not to describe them, and not to show alerts or printouts in the console, do the Do-Catch statement is the best approach.
@NiggaInTech
@NiggaInTech 2 роки тому
Brruuhhhhhhhhhhhh 😩🙏🏿
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
😅😂
@williamwildsmith5162
@williamwildsmith5162 Рік тому
I get 56 bytes. I knew I was special.
@giorgimeqvabishvili8210
@giorgimeqvabishvili8210 Рік тому
Thanks a lot Nick, you are very handsome
@cyberguy6100
@cyberguy6100 Рік тому
Heeeeeyyy bro ur legend i want the codes files u write can u give me github link for it The bootcamp files u create in xcode 3>
@yasseraltamimi6171
@yasseraltamimi6171 2 роки тому
I hate you so much lool, you did all of that at the beginning and I was like, nooo I'm not gonna do all of that for every model, then BOOM!! Just Codable! 😂😂😂😂
@SwiftfulThinking
@SwiftfulThinking 2 роки тому
😅 Hahaha yea I had to, otherwise you'd have no idea what was really happening under the hood lol
@creativevision9204
@creativevision9204 7 місяців тому
Awesome explaination. One of the must watch videos if you want to learn #Swift
@tibettenballs4962
@tibettenballs4962 Рік тому
Who is this jayson you keep talking about? sounds like you have a crush on him/her..
@hihiweiping
@hihiweiping Рік тому
Thank you so much Nick!! 🙏🙏🙏 I am super appreciated your efforts to make these amazing tutorials which help me a lot. Nice, clear explanation in proper order. 🦸🧙‍♂ I would definitely recommend this channel to all of my friends who want to learn swiftUI.
@SwiftfulThinking
@SwiftfulThinking Рік тому
Thanks! 🤓
skibidi toilet 73 (part 2)
04:15
DaFuq!?Boom!
Переглядів 31 млн
Піхотинець - про рутину на фронті
00:46
Суспільне Новини
Переглядів 1,2 млн
Маленькая и средняя фанта
00:56
Multi DO Smile Russian
Переглядів 1,9 млн
Sort, Filter, and Map data arrays in Swift | Continued Learning #13
28:36
Swiftful Thinking
Переглядів 19 тис.
How China Is Using Artificial Intelligence in Classrooms | WSJ
5:44
The Wall Street Journal
Переглядів 3,3 млн
How to use Generics in Swift | Advanced Learning #8
19:24
Swiftful Thinking
Переглядів 13 тис.
Download and save images using FileManager and NSCache | Continued Learning #28
1:09:52
What is JSON - JSON Parsing in Swift
24:15
CodeWithChris
Переглядів 72 тис.
How to use Timer and onReceive in SwiftUI | Continued Learning #24
26:17
Swiftful Thinking
Переглядів 20 тис.
Codable in Swift 5: What is it & how to use? (Xcode 11, 2020) - iOS
14:17
What is Modbus and How does it Work?
8:58
RealPars
Переглядів 1,6 млн
skibidi toilet 73 (part 2)
04:15
DaFuq!?Boom!
Переглядів 31 млн