Great video! I usually have two completion handlers: A successful one and a failure one (is that bad?) and I call the one that makes sense. I think I'll change to this solution :) I really liked that! Thanks for the tip. I am a new follower and your channel is helping me a lot!
Sean Allen following all your videos... just a suggestion that nowadays Unit testing or TDD approach would be useful and shifting focus from OOPS to POP .... if possible can make real time example using protocol oriented programming with use of DI would be helpful for ios people. Not talking about Hello World kind example but actual xCode small tutorial...
The example project is from my take home project course. That's a method we created to call our custom alert and show it on the main thread. You can find more information about the course and watch the first hour for free at seanallen.teachable.com
Hey Sean, I'm certain you've talked about it before, but what Xcode plugin do you use to align your variables like that at 1:42? If anyone knows could you let me know in the reply section?
It does... and you'll find a lot of developers that don't like it for that reason. If you do this in a non-personal project, I would expect some pushback on it.
Great video as always. Also, may I know how do you keep your code formatting so clean? My code is messy and it gets even worse when there is a code snippet copied over from other places. Do you use any tool to format the code or just do it manually? Thanks!
Thanks! I don't use a tool, I just make it a priority to make my code formatted neatly because I'm huge on a readable codebase. Code format is just one part of that.
Very useful your videos as always. I have only one recommendation. I think isn’t good create a whole method for each API call, you should create a generic type instead so you wouldn’t have many method with the same code.
Thanks! For context, this sample code is from my take home project course that's aimed at beginner developers looking to get their first job. For that reason, I demonstrated the network calls the "long way" so I could spell everything out and explain all the details for educational purposes.
Hi @sean, I’m a big fan of ur videos. I implemented result type in my project and I’ve been having a hard time wrapping my head around it. What i do before is i create a model for my 200 and 400 response so as to display a toast containing my response but I’ve been unable to decode and pass the 400 error to my enum. I really need your help.
In this example, we attached a string to our errors. In the networking code (where we call completed with either failure or success), you can check the response.statusCode. So you could do something like if response.statusCode == 401 { completed(failure(.mySpecial401Error)) }. This will pass the failure case with the error attached, which in turn has a string attached that you can display in your toast.
Sean Allen thanks for ur reaponse. I think u dont get my question. What i mean is in scenario where i need to decode both 401error and 200 success. Cause at my work place we always display the decoded message from status code == 401 as a toast
I've found this works best when combining Result, DataTask, and Codable with generics. Essentially decoding your network response data as the lhs of your completion closure. I've got plenty of code to share if you want to do a follow up.
Hey Alex, I appreciate that! For context, this sample code is from my take home project course that's aimed at beginner developers looking to get their first job. For that reason, I demonstrated the network calls the "long way" so I could spell everything out and explain all the details for educational purposes.
Good video. But I think depending on the use case, the old way is still valid. Imagine, if you have several method calls one after the other, which can fail. So, essentially you "jump" out of the success case right after the switch statement and call the next failable method OR you nest calls in the success case. So, that is were guard let comes into play. You first handle all the failure cases of the method calls and after that you can cleanly code your success case. So, it's good that we have another way of dealing with failures, Maybe in future there will be some common way on how to use the new result type in the case of several failable methods
Hey Sean, thanks for the video! Question how do you get your variables so nicely aligned? Within the method ScrollViewDidEndDragging the offsetY contentHeight and height variables with the assigned values are spaced out nicely, do you do this manually? Or is it a setting in Xcode that automatically formats them?
Hey, Sean ! Can you please explain network calls from closure-related point of view? I don’t really get it, it f*cks me a lot, cause I simply can’t grasp this concept. For example: How does completion handler work there? Or, this line : guard let self = self else { return }. I tried to google it, and it’s called strongify self, but I don’t understand what it really does... It would be great if you could explain these moments. Thank you.
Hey Alex, this would be way too much to explain by typing in a comment. I'll add it to my video idea list. Although, I do explain in the course where this code sample is pulled from if you're interested. seanallen.teachable.com.
Amazing video !! 👍🏼 Can you please do a video or link us to a source of information about firebase friend invitation request ! For example, user A wants to invite user B as friend, that will not happen till user B accepts the invitation.Currently kinda struggling with friend invitation requests Thanks in advance 🙏🏼
This is really good, but I disagree that anything is ambiguous. It's verbose, it's messy, but it's not ambiguous. But, basically, it seems to boil down to something parallel to optionals. With optionals, there are two values: nil or not nil, but with not nil, there is an associated value. Same thing here. There are two result values: success or failure. And each one has an associated value. Very useful, thanks, but I'd just discuss it differently....
I see what you're saying, and maybe "ambiguous" was too strong of a word. I wanted to demonstrate how, in my opinion, the call site using Result is MUCH more readable and clear.
Awesome, Sean. Please do more of these non-beginner videos. Big fan of these
I have a mixture of beginner and non-beginner videos on my to-do list.
I definitely need to use result type more often 😄
I had some troubles with passing server direct errors to user with this method but finally it's working, Thank you Sean.
Happy to hear it helped, Ahmad!
You can use the enum with an associated value. If you have any other solutions, please share.
@@NITINAGAM Yea I used enum with an associated value...
Thanks Sean, my network call was incomplete and I didn’t notice that, I definitely you change my code looks more cleaner and easy to read.
No problem 👍
Pretty good tutorial, this will make my networking calls a lot more cleaner!
Great to hear!
Cleaner networking!
Thanks, Sean great video!
Great 👍, I love this new feature too.
In error type, better to use errors conforming to LocalizedError protocol
Thanks for the tutorial Sean!!!
Happy to help!
Awesome explanation, thanks Sean.
Glad you liked it
Loving this content! A lot of stuff to learn during these times to stay productive. Thanks, Sean!
I think the same! Keep on Sean!
Glad you like them, Liana!
keep doing what you doing
Will do!
Very Nice Tutorial 🥰
Thank you, great tutorial.
Awesome tutorial Sean... :)
Glad you liked it!
Great video! I usually have two completion handlers: A successful one and a failure one (is that bad?) and I call the one that makes sense. I think I'll change to this solution :) I really liked that! Thanks for the tip. I am a new follower and your channel is helping me a lot!
Yes, using Result type is now the preferred way in most scenarios since it was introduced. Happy to hear you are enjoying the channel!
DUDE THANK YOU
Happy to help, Will.
You nailed it 🪓
Thanks Sagar!
Sean Allen following all your videos... just a suggestion that nowadays Unit testing or TDD approach would be useful and shifting focus from OOPS to POP .... if possible can make real time example using protocol oriented programming with use of DI would be helpful for ios people. Not talking about Hello World kind example but actual xCode small tutorial...
great tutorial and excellent explanation, I really enjoyed watching it, keep it up
Thanks Abdulaziz!
Very cool stuff. Out of curiosity, what's in the presentGFAlertOnMainThread method?
The example project is from my take home project course. That's a method we created to call our custom alert and show it on the main thread. You can find more information about the course and watch the first hour for free at seanallen.teachable.com
Sean Allen thank you, I'll check it out.
The timing of this video is superb lol
Glad to hear that!
really thank you I need it , made the life cleaner and esaier
Thanks Sean, love these tutorials
Glad you like them!
Hey Sean, I'm certain you've talked about it before, but what Xcode plugin do you use to align your variables like that at 1:42? If anyone knows could you let me know in the reply section?
I just tab them over and line them up myself.
@@seanallen That takes some serious dedication. Thanks for the response Sean and keep up the great work. I learn a lot from you.
It does... and you'll find a lot of developers that don't like it for that reason. If you do this in a non-personal project, I would expect some pushback on it.
Thanks Sean!
No worries!
That's a great help. Thank You ⭐️
Glad it was helpful!
@Sean Allen, did your Donny Wals’ book on combine?
I have it... haven't had a chance to dive in yet, but soon.
Great video as always. Also, may I know how do you keep your code formatting so clean? My code is messy and it gets even worse when there is a code snippet copied over from other places. Do you use any tool to format the code or just do it manually? Thanks!
Thanks! I don't use a tool, I just make it a priority to make my code formatted neatly because I'm huge on a readable codebase. Code format is just one part of that.
Great video sean.! For Network Call you were using class is there any reason for that or we can use struct?
In my case, my Network Manager is a singleton, so it's a class
Thanks, my man
Great tutorial, I like it.
Thank you! Cheers!
Very useful your videos as always. I have only one recommendation. I think isn’t good create a whole method for each API call, you should create a generic type instead so you wouldn’t have many method with the same code.
Thanks! For context, this sample code is from my take home project course that's aimed at beginner developers looking to get their first job. For that reason, I demonstrated the network calls the "long way" so I could spell everything out and explain all the details for educational purposes.
What about exceptions? Why don't we use throws in th e first place?
Hi @sean, I’m a big fan of ur videos. I implemented result type in my project and I’ve been having a hard time wrapping my head around it.
What i do before is i create a model for my 200 and 400 response so as to display a toast containing my response but I’ve been unable to decode and pass the 400 error to my enum.
I really need your help.
In this example, we attached a string to our errors. In the networking code (where we call completed with either failure or success), you can check the response.statusCode. So you could do something like if response.statusCode == 401 { completed(failure(.mySpecial401Error)) }. This will pass the failure case with the error attached, which in turn has a string attached that you can display in your toast.
Sean Allen thanks for ur reaponse. I think u dont get my question. What i mean is in scenario where i need to decode both 401error and 200 success. Cause at my work place we always display the decoded message from status code == 401 as a toast
I've found this works best when combining Result, DataTask, and Codable with generics. Essentially decoding your network response data as the lhs of your completion closure. I've got plenty of code to share if you want to do a follow up.
Hey Alex, I appreciate that! For context, this sample code is from my take home project course that's aimed at beginner developers looking to get their first job. For that reason, I demonstrated the network calls the "long way" so I could spell everything out and explain all the details for educational purposes.
Good video. But I think depending on the use case, the old way is still valid. Imagine, if you have several method calls
one after the other, which can fail. So, essentially you "jump" out of the success case right after the switch statement and call the next failable method OR you nest calls in the success case. So, that is were guard let comes into play. You first handle all the failure cases of the method calls and after that you can cleanly code your success case.
So, it's good that we have another way of dealing with failures, Maybe in future there will be some common way on how to use the new result type in the case of several failable methods
Hey Sean, thanks for the video! Question how do you get your variables so nicely aligned?
Within the method ScrollViewDidEndDragging the offsetY contentHeight and height variables with the assigned values are spaced out nicely, do you do this manually? Or is it a setting in Xcode that automatically formats them?
I tab them over manually
Helpful👏
Hey, Sean ! Can you please explain network calls from closure-related point of view? I don’t really get it, it f*cks me a lot, cause I simply can’t grasp this concept. For example:
How does completion handler work there? Or, this line : guard let self = self else { return }. I tried to google it, and it’s called strongify self, but I don’t understand what it really does... It would be great if you could explain these moments. Thank you.
Hey Alex, this would be way too much to explain by typing in a comment. I'll add it to my video idea list. Although, I do explain in the course where this code sample is pulled from if you're interested. seanallen.teachable.com.
Amazing video !! 👍🏼
Can you please do a video or link us to a source of information about firebase friend invitation request ! For example, user A wants to invite user B as friend, that will not happen till user B accepts the invitation.Currently kinda struggling with friend invitation requests
Thanks in advance 🙏🏼
10/10
Just in time to replace all this networking code with combine
There will still be a TON of UIKit out there for years to come 😀
Sean Allen I mean you can use Combine with UIKit too!
I used to pass in a viewController on a network method so I could present an error, this way is much better!
Happy to help with a new way to do things, David!
This is really good, but I disagree that anything is ambiguous. It's verbose, it's messy, but it's not ambiguous. But, basically, it seems to boil down to something parallel to optionals. With optionals, there are two values: nil or not nil, but with not nil, there is an associated value. Same thing here. There are two result values: success or failure. And each one has an associated value.
Very useful, thanks, but I'd just discuss it differently....
I see what you're saying, and maybe "ambiguous" was too strong of a word. I wanted to demonstrate how, in my opinion, the call site using Result is MUCH more readable and clear.