|
The same with
Also relevant for all the code stuff I suppose. |
|
Good Questions all around. I'll give it my best: 1- As you know, functions (or methods) can sometimes take parameters. These parameters are sometimes closures. Let's say for example, that a function takes 1 parameter with a label "age" and a second parameter which is a closure. Then when you call that function, you would do something like this:
But, if the function only takes a closure for it's parameter then you can write it in 2 ways
Because the closure is the only parameter you can skip the parentheses. By default, the autocomplete will use the first option, but you can use the second version. 2- Some functions provide you with "data" or "results". basically some kind of information. These values are accessible to you within the closure. Sometimes it's just one. Sometimes it's more. In the case of 3- self took me some time to understand, and I still don't think I understand it 100%. Basically, when we type self, we are referencing self. There is some performance related stuff here. What I can tell you confidently is that recently there has been a change that allows you to skip using self. This is called If you want more details about self, check out Sean Allen's video linked below: https://www.youtube.com/watch?v=bBXdXmUobMw 4- That is the ultimate skill. I would practice this as much as possible. To answer your question though, there are a couple of things to do here. a- b- Check Developer Documnetation. Whether you do it on the website or c- There is a paid alternative for SwiftUI. If you want a better resource for documentation, with examples, the app is called "A Companion to SwiftUI". Personally, I absolutely love it. But again, it's paid so not for everyone. To use an example from what we discussed above, try it on
That tells you quite a bit already. It takes a single parameter (unnamed at the call site) and returns
It says that the closure will contain the final value. So now you know you have to use There is another way these individuals get their information. They checkout Swift.org and read the source code. But that's a bit advanced for me and I'm not really interested in it. I hope the above answers your questions 😉 |
|
@MarcusKay thanks immense for profound answer!!! As of question 4, thank you very much for tips! Also, understood why
doesn't need I found helpful to read swift.org along with tutorials (I'm only on the 1/3 of it). It's although not easy read, but if distributed well through span of time, it's, probably, possible to finish. I think it gives the foundational knowledge, that developer can leverage further, and more smoothly adapt to changes whatever they be. That also helped me in a sense - when I do tutorials, I'm more aware what the tutor is talking about and less loose the thread of thought. |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.