In my opinion Ravi has explained Closures far better than Sean Allen and Let’s build that app channel or any other channel. He is India version of making rich quality content on swift and helping the developer community. Can’t wait till he starts teaching other topics i wonder how many thing we will re-learn from him
Yo Man, I agree, His depth of knowledge is superb and his way of teaching is too good, He is really a Indian apple documentation for us. which teach us How? Why? and what make it good. Thanks Codecat.
@@goretushar37 Indian apple documentation was a new compliment thanks hahaha, I think every developer should know at least what they are coding and why and what could be the impact of this code. Thank you for such wonderful and kind words
@madmax coder: Sean Allen and Let's build the app are good channels no doubt and I am honored to know that this channel is being compared to such wonderful channels, slowly I will release more content for the community and will share my views on multiple topics. Once again I am thankful for your comments and good to know that this channel is being helpful for swift devs.
@@CodeCat15 Yes honestly, you have really very great content, although I just want to let you know your videos are not in sequence, I was trying to see API Calls playlist and there after watching one video when I went to another It started explaining POST, and gave references to previous videos of GET. which wasn't there in playlist, could you please rearrange and cross check your playlists?
I am only halfway through the video right now, and as soon as you explained what the real meaning of CPU resource wastage is, by illustrating an unwanted function call, I told myself this is the best explanation that I have ever seen. Had to comment and let you know even though I am not yet done watching.
Whenever I just got stucked up trying to understand something , Ravi's videos actually explains everything in detail and also helps with other related topics too . Your explanation is really so simple and easy to understand .
Hello Ashish, welcome to the channel. Thanks for the kind words dude means a lot, am glad this video was helpful to you. Please feel free to ask questions if you have any and do share the channel with your iOS group or with anyone who wants to learn swift programming the right and easy way 😊
So, one should use closure as a function parameter in place of function itself as a parameter value due to function call sequence. Got this point for the first time. Great!
these were one of those times I was experimenting and trying weird things with closures and came across this so thought of sharing what closures can do.
@@CodeCat15 I need to connect with you if it is possible as I want to make my career in iOS. I have been learning iOS development for 8 months, but I need a mentor someone like you who has a good grip over iOS stuff.
Yes . Agree with others. I have seen many videos of closures and j was not sble to understand but after watching this video i am able to understand 70% about closure. I have a suggetion . Please make video on equtable , comparable , Iteratable , hashable and subscript. Thank you.
I am glad this video was helpful to many devs trying to get the essence of closure, I agree with your request as i think this is something that needs to be covered from an interview point of view as well, actually there are lot of topics on the back burner but for some reason i been getting lot of requests on swiftui videos and hence am making them, but let me get back to swift programming in few weeks and start with something very interesting.
Ravi please do upload more and more such videos where you help us understand tech jargon through simple and relatable use cases. Every other CZcamsr simply gives their own version of a textbook definition but you really make a point that sticks around and it makes me reflect on it later at a conceptual level.
Thank u very much such informative tutorial it would be very helpful if there's specific video or recommendation for escaping and non escaping closures. Thanks in advance.😊
Hi Ravi, like first video, if we declare like this let additionClosure: (Int, Int) -> Int = { (number1, number2) in return number1 + number2 } It also accepted. instead of (number1: Int, number2: Int)
Escaping closure humne api series mai bahut use kiya hai aur vaha maine usse cover kiya hai, aur isiliye maine is video mai jayada escaping closure k baare mai jayada nahi bola. Video aur channel dono ko share zaroor karna aapne iOS group k saath and thank u for your kind words Chandan 😊
CodeCat: Nice video, got idea of so many things related to closure. Function call sequence with closure is so confusing though, while calling printGoodMorningMessage you have sent only one parameter within () these brackets & closure body was outside the same. I thought it has to be sent within (), tried that & it worked too (below) printGoodMorningMsg(flag: true, name: { () -> String in return name })
If you would have used escaping closure instead of that then the it will check if condition at first and then it will implement the closure part but default one is non escaping which is name so not able to figure it out...Please clear my doubt here...
or may be because if we pass closure as a parameter in a function then we can add functionalities in a function call so we called assignName in function call.So it called the goodmorning function first checked boolean value and then called assignName as per boolean value.
Thanks for the comment Anil, there's more to come regarding swift programming in the coming days. If you have any questions then please feel free to ask and do share the channel with your iOS group on social media.
Hey i like you content very much , and i think you missed the very imp concept in closure that in memory management inside closure Hope you make a video soon on that topic .. Thanks keep going keep motivating us..
Awesome i am glad this was helpful, i will try to make a video in coming days for capture list as well palak, do share this video with your friends who are iOS developers OR who are learning swift on whatsapp group or Facebook
Thanks @Mukul for your kind words, am just trying to explain what’s the right technique that every iOS developer should know. I am really glad that these videos are being helpful to the community. Btw regarding the advance topics are there any specific topics you want me to target?
Sure, in the api series we made a httpUtility where we are using the escaping closure to return the decoded object from the api. Here’s the link to that video do check it out and let me know if you still have questions. Link: czcams.com/video/pnMip8Gpa0w/video.html
So it means in escaping closure: function will call first then closure will call and in non escaping closure : closure will call first then function will call?
yes that's correct, think of escaping as a function hook, the escaping closure carries out it's business in a separate thread and then returns back the information to the same function where it was called
Hello! We use different UI objects like button label, as well as controllers like navigation controller, view controllers, table view controllers, etc So my question is How do we know which method or function we should use for a particular UI object or controller? For example, a navigation controller has many methods, how we know which method is suitable for a particular thing. In other words, there are so many inbuilt methods and properties. so my question is, how we know when which method or property should use, how to the parameter we can pass to a custom method. please help !
I think for this you have to practice a lot, and go through the developer documentation and spend time with the system, the more you practice the more you become aware of the core functioning of the system and the do's and don't. SwiftUI is new so there are tons of new features apple added, few of them I know, but then few are complete revamp from how things were done in UIKit so I read the documentation, blogs or some StackOverflow answers but to be honest, practice has always been the most crucial element in learning and understanding anything.
@@CodeCat15 Agree! Definitely, a lot of practice is required. (I thought there may be a technique to use a particular method ;), so I asked the question) BTW, can you please make a video on how to read/Use apple's developer documentation with example (because like me many other beginners have much difficulty to find particular method in apple's developer documentation)
Yeah i agree the apple dev documentation sometimes appear to be very cryptic, but for swift my first stop is swift.org which explains with pretty good examples however the ui documentation is a different story and has less examples, will try and cover that in some of my videos
No, escaping and non-escaping closures in Swift programming language are not the same as async/await in C#. In Swift, an escaping closure is a closure can be executed at a later time, even after the function has returned. A non-escaping closure in Swift is a closure that is executed within the function's scope and doesn't outlive the function itself. In C#, async/await is used to write asynchronous code that allows tasks to be executed concurrently without blocking the main thread. They are different concepts and have different syntax and usage in their respective programming languages.
Hey there @Runku welcome to the channel, i just released a video on the basics of core data do check that out and in the core data series this is indeed one topic which i will cover in the coming days. If you have any question on closure or even core data please do feel free to ask and do share this channel with your iOS group on WhatsApp or Facebook
So adding the video numbers was a bad idea from my end, i will be skipping video number from now on, sorry about the confusion buddy. If you are looking for the sequence then I request you to checkout the playlist section where videos are arranged in their respective sequence.
Sir if I want to call an api in the escaping closure in some file and when api ends its execution then I want to return the data to another ViewController and put that data on the label of that viewController on the time of screen appears. Please help me on this I am so frustrated due to this.
you would have to call the api in that view controller let's call it ViewController A in the VC-A you will find a method called as viewWillAppear in that method make the API call and once you get the data, reload the label in the main queue. Please refer to my API playlist over there I have few examples of this and if that does not help please ping on my discord server iOS Cafe
You know i have thought about it a lot to have my own interview series and i surely will release it in the coming days, how do you want the video to be like do you want me to explain the answers or just generally go with the questions that i ask?
Hello Praveen welcome to the channel, Atomic and non atomic are objective c parts, however they were used for threading where atomic was thread safe and non atomic was not thread safe. Recently in swift 5.3 apple has added atomic property wrapper which are like objective c atomic property and am going to release a video on that soon.
are you using MVP pattern in your project? That's nice actually, what was the technical decision that made you choose MVP and not MVC if you can share this.
the name that you see is just used for reference purpose i.e. how declaring a closure or type alias for closure is pretty similar to declaring a variable.
i have write a code like below to test func demoFunc(number:Int,closureNames:(Int,Int) -> Int { print("\(number)") print(closureNames(30,50) } demoFunc (number:10,closureName:{ (a:Int,b:Int) -> Int in return a + b } it shows output 80,but when i use @autoclosure like below - it shows error func demoFunc(number:Int,closureNames:@autoclosure(Int,Int) -> Int { print("\(number)") print(closureNames(30,50) } i want to know why it hows error, cant we pass two arguments using @autclosure?
let me start by saying this that autoclosures should not be used at all because they hide implementation details which I also mentioned in the video. Autoclosure cannot be used with parameters so even if you write the code as func doSomething(myClosure:@autoclosure(Int) -> Int) the compiler will raise a compile time error, you will hardly come across a use case in programming where you want to use autoclosure, and even apple recommends not to overuse them. Hope I was able to clarify your question if not then please do ask
Sorry about the speech Anita, I was still very new to CZcams. Escaping closures help us to return values from any background operations. URLSession calls an api in the background and when it has a response you return the response using the @escaping. By using @escaping you tell swift that there’s a background task which will return a value and use this @escaping closure to return me the value. Hope that covers it and if not feel free to let me know and I will try covering this in a blog or video for the same.
I think i have explained the [weak self] portion in the delegate closure video do check that out Link: czcams.com/video/UafLiRvBwNA/video.html However unowned self is something that i have not explained so let me work on that, thanks for making this request Saravanan and welcome to the channel 😊
if you do it little slower its more better. than .. this.. its getting over .. I have to watch it again and again.. to get it you can type code faster but make that sense or understanding for that code slower.. so that everything will be clear.. its getting complex .. You spoked too fast.. this this this this.. I found you video is best over others. ,,you but you spoiling it understanding ...
I want to apologize for speaking too fast, I will work on it and be better next time. I really appreciate the feedback it means a lot. If there’s something else which i can improve and be better then please do tell
My advice if not taken in the wrong way, I hope there is always have a speed control playback speed 0.25x, .5x, .75 x and this should ease the problem for viewers and vlogger.
No that’s not true at all, closure don’t cause memory issues unless the code we write is incorrect like we fail to use [weak self] in closure as i explained in the delegate pattern video using closure.
I will find it strange that a typealias or lazy could cause any leaks but unless i see the code l won’t comment on it coz mostly it depends on how the developer is using them, but in theory they should not cause any leaks unless the underlying implementation is not done right.
@@CodeCat15 i had an interview why lead Developer , he told me that but typalias and lazy variables are causing memory leaks in some cases. but i didn't perform testing yet
Let me give you an example agar insaan ko bukhar hai to doctor usse body pain ki davai to nahi dega, Doctor pata karengaye ki bimari kya hai aur us hisaab se davai dega, Kuch creative doctors galat davai de sakte hai bina koi test kiye, aur galat davai dene se kya hoga ye to aap jaante ho. when a dev tells me that its a leak coz of lazy or any other thing then i would ask him proof and some data matrix which proves that the leak is coz of the lazy variable or anything else, in programming we cannot assume things and hence we need proof or some test cases or instrument debugging to prove the origin of leak Varna pata chala leak kisi aur code ki vajaha se ho raha hai aur aap koi dusra code fix kar rahe ho, aise assumption basis pe kaam karogaye to aapka time waste hoga aur kuch nahi so ask the dev proof and origin of the leak. Hope it helps 😄
In my opinion Ravi has explained Closures far better than Sean Allen and Let’s build that app channel or any other channel.
He is India version of making rich quality content on swift and helping the developer community.
Can’t wait till he starts teaching other topics i wonder how many thing we will re-learn from him
Yo Man, I agree, His depth of knowledge is superb and his way of teaching is too good, He is really a Indian apple documentation for us. which teach us How? Why? and what make it good.
Thanks Codecat.
@@goretushar37 Indian apple documentation was a new compliment thanks hahaha, I think every developer should know at least what they are coding and why and what could be the impact of this code. Thank you for such wonderful and kind words
@madmax coder: Sean Allen and Let's build the app are good channels no doubt and I am honored to know that this channel is being compared to such wonderful channels, slowly I will release more content for the community and will share my views on multiple topics. Once again I am thankful for your comments and good to know that this channel is being helpful for swift devs.
@@CodeCat15 Yes honestly, you have really very great content, although I just want to let you know your videos are not in sequence, I was trying to see API Calls playlist and there after watching one video when I went to another It started explaining POST, and gave references to previous videos of GET. which wasn't there in playlist, could you please rearrange and cross check your playlists?
@@harshitjain7428 Exactly Harshit...I also faced the same issue. I also commented the same...Lets see.
I am only halfway through the video right now, and as soon as you explained what the real meaning of CPU resource wastage is, by illustrating an unwanted function call, I told myself this is the best explanation that I have ever seen. Had to comment and let you know even though I am not yet done watching.
Welcome to the channel Harsh, I am glad this video was helpful 😊 please feel free to ask questions and do share the video with your iOS group
Whenever I just got stucked up trying to understand something , Ravi's videos actually explains everything in detail and also helps with other related topics too . Your explanation is really so simple and easy to understand .
I am glad these videos are helpful Sharath, and thank you for your kind and bright words 👍
You make developer's life easier dude. Thanks a lot..!! You teach in a very easy and professional way that anybody can understand easily. :)
Hello Ashish, welcome to the channel. Thanks for the kind words dude means a lot, am glad this video was helpful to you. Please feel free to ask questions if you have any and do share the channel with your iOS group or with anyone who wants to learn swift programming the right and easy way 😊
So, one should use closure as a function parameter in place of function itself as a parameter value due to function call sequence. Got this point for the first time. Great!
these were one of those times I was experimenting and trying weird things with closures and came across this so thought of sharing what closures can do.
best closure describing video I have ever seen. TBH.
Thank you Mustafa I am glad this was helpful :)
@@CodeCat15 I need to connect with you if it is possible as I want to make my career in iOS. I have been learning iOS development for 8 months, but I need a mentor someone like you who has a good grip over iOS stuff.
Bahot badhiya content bhai, the explanation is very good. First-time closure samajh aa gaya easily.
glad it was helpful
Yes . Agree with others. I have seen many videos of closures and j was not sble to understand but after watching this video i am able to understand 70% about closure. I have a suggetion . Please make video on equtable , comparable , Iteratable , hashable and subscript. Thank you.
I am glad this video was helpful to many devs trying to get the essence of closure, I agree with your request as i think this is something that needs to be covered from an interview point of view as well, actually there are lot of topics on the back burner but for some reason i been getting lot of requests on swiftui videos and hence am making them, but let me get back to swift programming in few weeks and start with something very interesting.
Great job buddy .. keep it up .. we are waiting for yours videos
I am glad this video was helpful for you, thank you for your comment, do subscribe and share it with your iOS group
Ravi please do upload more and more such videos where you help us understand tech jargon through simple and relatable use cases. Every other CZcamsr simply gives their own version of a textbook definition but you really make a point that sticks around and it makes me reflect on it later at a conceptual level.
Simplicity is what I always try to aim for 😊
Appreciate your hard work in making those videos. I learn many things from your channel.
Thank you for making those videos.
Thanks Nikhil, please feel free to ask questions and do share the channel with your iOS group
Thank u very much such informative tutorial it would be very helpful if there's specific video or recommendation for escaping and non escaping closures.
Thanks in advance.😊
Hi Ravi, like first video, if we declare like this
let additionClosure: (Int, Int) -> Int = {
(number1, number2) in
return number1 + number2
}
It also accepted. instead of (number1: Int, number2: Int)
All videos are great and we get good knowledge thanks for sharing
Explanation are also very good
Thank you for your kind words
sir nice tutorial, lakin aapko escaping closer kaa 1 example dena chahiye tha. or acche se samajh me aa jaata... and your video is a Premium Quality
Escaping closure humne api series mai bahut use kiya hai aur vaha maine usse cover kiya hai, aur isiliye maine is video mai jayada escaping closure k baare mai jayada nahi bola. Video aur channel dono ko share zaroor karna aapne iOS group k saath and thank u for your kind words Chandan 😊
@@CodeCat15 ok sir
Thanks for this video, the only remark is that is better to stick with one voice language switching between english and hindi making hard to follow.
vary helpfull learnins, thank you for your efforts, god bless you
Thank you for the kind words Shivam, am glad the video is helpful
CodeCat: Nice video, got idea of so many things related to closure.
Function call sequence with closure is so confusing though, while calling printGoodMorningMessage you have sent only one parameter within () these brackets & closure body was outside the same. I thought it has to be sent within (), tried that & it worked too (below)
printGoodMorningMsg(flag: true, name: { () -> String in
return name
})
Hi Ravi Sir, Please help on this one too....
You explained Closure part very well but still i am not getting auto closure completely.
Video is really very informative but how adding the closure changed the sequence of execution? Need some more clarification on that.
what do you think could be the reason for this?
@@CodeCat15 The name closure which is used in code is non-escaping so not able to figure out how the sequence got changed....
If you would have used escaping closure instead of that then the it will check if condition at first and then it will implement the closure part but default one is non escaping which is name so not able to figure it out...Please clear my doubt here...
or may be because if we pass closure as a parameter in a function then we can add functionalities in a function call so we called assignName in function call.So it called the goodmorning function first checked boolean value and then called assignName as per boolean value.
@@CodeCat15 We are checking the isMorning condition first and then calling the closure name() there..Is that the reason?
Capital list with closures. I think that is most important topic when you are working with closure especially during heavy weight / api functions
I have just finished this beginner playlist. Please Suggest the next playlist to start which i can complete as a whole from start to end.
Protocol oriented programming and then watch code like a pro
You are a very good tutor brother. Thanks!!
Thank you 😊
Awesome job Ravi 🙏
am glad this was helpful
Awesome!!!
Thank you Cheers
Superb
I am glad this was helpful Vaibhav.
@codeCat - Thanks Sir, very informative video. I would love to learn more from you.
Thanks for the comment Anil, there's more to come regarding swift programming in the coming days. If you have any questions then please feel free to ask and do share the channel with your iOS group on social media.
Hey i like you content very much , and i think you missed the very imp concept in closure that in memory management inside closure
Hope you make a video soon on that topic ..
Thanks keep going keep motivating us..
Thanks for a Great explanation of closures.
Do feel free to ask questions Ram and do share this with your iOS group on WhatsApp or Facebook
thanks Ravi
Welcome 😀
Maza aa gya
Thank you Ravi❤
Thank you Rajesh :)
Hello Ravi can u make a one video about the memory leak in closure i seen u r video its really good and easy to undestand
Thank you Ravi for the awesome videos. Please make a video on Capture list.
Awesome i am glad this was helpful, i will try to make a video in coming days for capture list as well palak, do share this video with your friends who are iOS developers OR who are learning swift on whatsapp group or Facebook
Nice explanation bro
Nicely Explained
Please come up with completion block in swift
Sir, can please upload escaping closure with one easy example
Very nice explanation.
Thank you Abhishek, plz feel free to ask questions on this topic and do share this video with your iOS group on WhatsApp or Facebook
Very Nice Video Bro, Wating for some Advance Topics. Good work for the community.
Thanks @Mukul for your kind words, am just trying to explain what’s the right technique that every iOS developer should know. I am really glad that these videos are being helpful to the community. Btw regarding the advance topics are there any specific topics you want me to target?
Code Cat 😊Would love to see Operation queues, GCD, memory management, Concurrency. 👍
Cool, and it’s been a while i talked about them after the threading series. Good that you raised this thanks @Mukul
Code Cat thanks its Mukul
Oops sorry about the typo @Mukul
Question - if we have closure as stored property then is it escaping or non escaping? And Why?
Sir can you please explain more in escaping closure. Please try to explain with realtime example like fetch images from Firebase.
Sure, in the api series we made a httpUtility where we are using the escaping closure to return the decoded object from the api. Here’s the link to that video do check it out and let me know if you still have questions.
Link: czcams.com/video/pnMip8Gpa0w/video.html
@@CodeCat15 Thanks a lot Sir...! I will sure ask if i will have any questions.
So it means in escaping closure: function will call first then closure will call and in non escaping closure : closure will call first then function will call?
yes that's correct, think of escaping as a function hook, the escaping closure carries out it's business in a separate thread and then returns back the information to the same function where it was called
Hello!
We use different UI objects like button label, as well as controllers like navigation controller, view controllers, table view controllers, etc
So my question is
How do we know which method or function we should use for a particular UI object or controller?
For example, a navigation controller has many methods, how we know which method is suitable for a particular thing.
In other words,
there are so many inbuilt methods and properties.
so my question is, how we know when which method or property should use, how to the parameter we can pass to a custom method.
please help !
I think for this you have to practice a lot, and go through the developer documentation and spend time with the system, the more you practice the more you become aware of the core functioning of the system and the do's and don't.
SwiftUI is new so there are tons of new features apple added, few of them I know, but then few are complete revamp from how things were done in UIKit so I read the documentation, blogs or some StackOverflow answers but to be honest, practice has always been the most crucial element in learning and understanding anything.
@@CodeCat15 Agree! Definitely, a lot of practice is required. (I thought there may be a technique to use a particular method ;), so I asked the question)
BTW, can you please make a video on how to read/Use apple's developer documentation with example (because like me many other beginners have much difficulty to find particular method in apple's developer documentation)
Yeah i agree the apple dev documentation sometimes appear to be very cryptic, but for swift my first stop is swift.org which explains with pretty good examples however the ui documentation is a different story and has less examples, will try and cover that in some of my videos
escaping clouser ke liye koi achha video pleause
Is escaping/non-escaping is same concept as C# has async/await?
No, escaping and non-escaping closures in Swift programming language are not the same as async/await in C#.
In Swift, an escaping closure is a closure can be executed at a later time, even after the function has returned.
A non-escaping closure in Swift is a closure that is executed within the function's scope and doesn't outlive the function itself.
In C#, async/await is used to write asynchronous code that allows tasks to be executed concurrently without blocking the main thread.
They are different concepts and have different syntax and usage in their respective programming languages.
hi please make a video on, how to save server data in core data?
Hey there @Runku welcome to the channel, i just released a video on the basics of core data do check that out and in the core data series this is indeed one topic which i will cover in the coming days. If you have any question on closure or even core data please do feel free to ask and do share this channel with your iOS group on WhatsApp or Facebook
bhai @escaping closure mai phle baaki sara code chalega fir closure ke andar wala?
correct
Please in thumbnail add video number, it's getting hard to find the sequence. else provide sequence on any social platform I will check from there.
So adding the video numbers was a bad idea from my end, i will be skipping video number from now on, sorry about the confusion buddy. If you are looking for the sequence then I request you to checkout the playlist section where videos are arranged in their respective sequence.
Sir if I want to call an api in the escaping closure in some file and when api ends its execution then I want to return the data to another ViewController and put that data on the label of that viewController on the time of screen appears.
Please help me on this I am so frustrated due to this.
you would have to call the api in that view controller let's call it ViewController A in the VC-A you will find a method called as viewWillAppear in that method make the API call and once you get the data, reload the label in the main queue. Please refer to my API playlist over there I have few examples of this and if that does not help please ping on my discord server iOS Cafe
enum in swift where and what use ? video
Please make an Interview Q&A series.
You know i have thought about it a lot to have my own interview series and i surely will release it in the coming days, how do you want the video to be like do you want me to explain the answers or just generally go with the questions that i ask?
@@CodeCat15 We would love to know the approach not full answers. Thanks in advance waiting for interview video.
Hello bro.. Your cliping is very helpful. I have a query if you will have time so Pls response me..
Q. How's working process of automic and nonatomic?
Hello Praveen welcome to the channel, Atomic and non atomic are objective c parts, however they were used for threading where atomic was thread safe and non atomic was not thread safe.
Recently in swift 5.3 apple has added atomic property wrapper which are like objective c atomic property and am going to release a video on that soon.
Thank bro.. I'll wait for next video
@Ravi: @autoClouser is escaping or non-escaping?
please explain escaping and non escaping closures more clearly
make a video on MVP please
are you using MVP pattern in your project? That's nice actually, what was the technical decision that made you choose MVP and not MVC if you can share this.
No I am making my project based on MVC , but I want to know about MVP.
Hey @codecat15, can you please tell which closure (escaping/non-escaping) can cause retain cycles, or both of them can cause it.
Closures don’t cause retain cycles its how we implement them, a good practice is to use weak self to avoid cycles
Can anyone please tell me how come name:() represent the closure?
the name that you see is just used for reference purpose i.e. how declaring a closure or type alias for closure is pretty similar to declaring a variable.
thumbs-up (y)
Thank you 😊 @Naina
i have write a code like below to test
func demoFunc(number:Int,closureNames:(Int,Int) -> Int {
print("\(number)")
print(closureNames(30,50)
}
demoFunc (number:10,closureName:{
(a:Int,b:Int) -> Int in
return a + b
}
it shows output 80,but
when i use @autoclosure like below - it shows error
func demoFunc(number:Int,closureNames:@autoclosure(Int,Int) -> Int {
print("\(number)")
print(closureNames(30,50)
}
i want to know why it hows error, cant we pass two arguments using @autclosure?
let me start by saying this that autoclosures should not be used at all because they hide implementation details which I also mentioned in the video. Autoclosure cannot be used with parameters so even if you write the code as
func doSomething(myClosure:@autoclosure(Int) -> Int)
the compiler will raise a compile time error, you will hardly come across a use case in programming where you want to use autoclosure, and even apple recommends not to overuse them. Hope I was able to clarify your question if not then please do ask
@@CodeCat15 yeah! Understood. Thank You
If there are any more questions plz feel free to ask i will be happy to answer them and do share this video with your iOS group 😊
sir, escaping closure is not very clear to me please make a simple video for this and please be a little slow you are very fast.
Sorry about the speech Anita, I was still very new to CZcams. Escaping closures help us to return values from any background operations. URLSession calls an api in the background and when it has a response you return the response using the @escaping. By using @escaping you tell swift that there’s a background task which will return a value and use this @escaping closure to return me the value. Hope that covers it and if not feel free to let me know and I will try covering this in a blog or video for the same.
Explain [weak self] and [unowned self ] in closure?
I think i have explained the [weak self] portion in the delegate closure video do check that out
Link: czcams.com/video/UafLiRvBwNA/video.html
However unowned self is something that i have not explained so let me work on that, thanks for making this request Saravanan and welcome to the channel 😊
if you do it little slower its more better. than .. this.. its getting over .. I have to watch it again and again.. to get it
you can type code faster but make that sense or understanding for that code slower.. so that everything will be clear..
its getting complex .. You spoked too fast.. this this this this..
I found you video is best over others. ,,you but you spoiling it understanding ...
I want to apologize for speaking too fast, I will work on it and be better next time. I really appreciate the feedback it means a lot. If there’s something else which i can improve and be better then please do tell
My advice if not taken in the wrong way, I hope there is always have a speed control playback speed 0.25x, .5x, .75 x and this should ease the problem for viewers and vlogger.
by using closures .. increase chances of memory leaks? is it true
what you say about type alias and lazy var for memory leaks?
No that’s not true at all, closure don’t cause memory issues unless the code we write is incorrect like we fail to use [weak self] in closure as i explained in the delegate pattern video using closure.
I will find it strange that a typealias or lazy could cause any leaks but unless i see the code l won’t comment on it coz mostly it depends on how the developer is using them, but in theory they should not cause any leaks unless the underlying implementation is not done right.
@@CodeCat15 i had an interview why lead Developer , he told me that but typalias and lazy variables are causing memory leaks in some cases. but i didn't perform testing yet
Let me give you an example agar insaan ko bukhar hai to doctor usse body pain ki davai to nahi dega,
Doctor pata karengaye ki bimari kya hai aur us hisaab se davai dega,
Kuch creative doctors galat davai de sakte hai bina koi test kiye, aur galat davai dene se kya hoga ye to aap jaante ho.
when a dev tells me that its a leak coz of lazy or any other thing then i would ask him proof and some data matrix which proves that the leak is coz of the lazy variable or anything else, in programming we cannot assume things and hence we need proof or some test cases or instrument debugging to prove the origin of leak
Varna pata chala leak kisi aur code ki vajaha se ho raha hai aur aap koi dusra code fix kar rahe ho, aise assumption basis pe kaam karogaye to aapka time waste hoga aur kuch nahi so ask the dev proof and origin of the leak.
Hope it helps 😄
May i know where are the API series related Videos ?
Here you go Govind
Api series playlist: czcams.com/play/PLb5R4QC2DtFuXr4177KQ2lIXOkqwq97a4.html
@@CodeCat15 Thank you so much for sharing and quick response...!
kanger