I am convinced Nick is the nicest person on earth, and/or struck it big with some dream job as a mobile dev, because MY GOD. This content is amazing. I am hoping there is more content from you after this basics course :) If not, I will be reading the entire Swift Textbook next.
Thanks very much for these well expressed lessons! It took me three days to get through the optionals as I could only deal with so much info inside of a couple hours. I'll likely forget half of what I learned, but at least there'll be bits of info that will service as hints going forth. There's a bit of confusion introduced in the last bit on chaining optionals. It's generally better to create copies of code blocks you're going to alter to illustrate concepts than returning to previous blocks and doing so. Each block the user creates (with commentary) is better left unedited avoiding typos and missed aspects like for instance the ?. I don't how others learn, but I need to follow along and type code to reinforce the info being conveyed. I'm also a lousy typist so I often get frustrated and lost.... But anyway - again - thanks very much Nick!
Optionals confused the hell out of me until this video. The examples showing distinctions between guard let of all three vars vs. layered guard was especially helpful. Thanks so much!
8:55 need to explain what ".description" do => gets you the value of "non-String variable" into a String value , so you can actually do "coalescing operator" and print a "string" value inside \( ) out of "Bool => non String dataType".
not and easy topic but i trust it will be important in the future, thanks for making such a detail explanation, I did some test printing things before and after unwrap and also the explicit of a nil to see it crash, it helped me understand a bit more.
Thanks, Nick, great explanation... I have seen in many articles, there is one more approach to unwrapped. let optional: String? = "I love Swift" if case let unwrapped? = optional { print(unwrapped) } is it the correct way?(for such a case)
Awesome! I have an idea for a calculation type app. The user would need to enter some values (how do convert a string to a double?) but of course when the app first opens there aren’t any values. Do these variables need to be optionals or can they be nil?
Man this video is amazing, you broke this down very well and simple. I been trying to understand optionals for a while, esp the guard statement, but with more practice, I think I understand the concept. Thank you
Nick, thanks so much for this one! Unwrapping and the use of guard was a gray area for me. You make it so easy to understand! Keep up the great work my friend!
Is there any way to help us visualize (via the console) functions "checkIfUserIsPremium" 1-6? It's quite confusing keeping the different constants and function names separated and understanding how each function works without seeing some final product.
thankyou Nick, For Non SwitData, objects above work well, but it seems if the object is from SwitData, no way i can delete optional input, for example : let input_ClientMst:ClientMst? // received from another view & i am checking for not nil ... if(input_ClientMst != nil) { modelContext.delete(input_ClientMst) } error Value of optional type 'ClientMst?' must be unwrapped to a value of type 'ClientMst' hope you can guide me , how to unwarp
Absolutely love the series, I have been getting bug messages from xcode, just by copying everything that he has written,"Main actor-isolated var 'userIsPremium' can not be referenced from a nonisolated context" if anybody can help explain I would really appreciate it
If you’re building this in Xcode, the new versions of Xcode run Swift 6, which is a more strict compiler. You can turn this off by going to the project navigator, clicking “Build Settings”, search for Swift Language Version, and revert it down to Swift 5. The warning is telling you that pieces of code can only be accessed on the “MainActor” which is the default thread where most of your code runs anyway. With the new Swift 6 compiler, we are now forced to explicitly tell the compiler if we’re are on the MainActor. This can usually be solved by just putting “@MainActor” before the “func”, “var”, “let”, “class” or other keywords. The MainActor is a more advanced topic that I cover in the Swift Concurrency playlist, but not something I would worry much about just yet!
Its providing me error when I am writing the optional code. Error - main actor-isolated var 'userIsNew' can not be referenced from a nonisolated context guard let userIsNew, let userDidOnboarding, let userFavouriteMovie else{ Is it because swift of the swift version because. it was working in the video Edit : got the answer , it is due to the swift version 6.0 . Swift came with the upgrade of complete concurrency checking is enabled by default. you have to add Main Actor annotation to make it work
@SwiftfulThinking could you please elaborate why we have to add Main Actor before my function declaration, i know its an update but can you please explain what it really does
I always get error "Variable binding in a condition requires an initializer" if I refactor the `if let isNew = userIsNew` to `if let isNew` . ChatGTP says that I need to keep the first version so how come it doesn't work? I ran `xcrun swift -version` on my terminal and it says `swift-driver version: 1.45.2 Apple Swift version 5.6.1`. Is the version too old to work with this new syntax you use?
I'm able to follow the code. But I don't fundamentally understand why I would ever use an optional? What is the benefit of it over a non-optional? Why do I want to have variables that are null? Wouldn't I just rather have a boolean with a default of false, an integer with a default of 0, or a string with a fault of empty?
There are times where we can use default values to avoid optionals, but providing a default value is not the same as not having a value. Imagine fetching the user’s age that fails. You could have a default age of 0 or leave it as optional. If it’s optional, you can unwrap it to check that there is an age. If it’s defaulted to 0, it would appear no different than successful. You’d likely need extra logic to confirm it’s not the defaulted value. But high level optionals are fundamentally build into Swift. As you start to build apps you’ll realize it’s a net positive for you as the developer. It’s not a question of “why would I want this” but “how can I handle this” 😅
@@SwiftfulThinking Thanks so much for the further explanation. That "age check" is a nice example. Overall, I'm really enjoying your videos. I have a simple appthat I intend to build when I finish the lessons and I'm sure some of these things (like optionals) that don't seem that important now, will make more sense when I start coding the app.
I've got a question for when I try to access variables in a function. E.g. in this code: var userIsNew: Bool? = true func checkIfUserIsSetup() { if let isNew = userIsNew { } } The Compiler always tells me to add @MainActor before the "func". So when I press on fix the code I end up with this code: var userIsNew: Bool? = true @MainActor func checkIfUserIsSetup() { if let isNew = userIsNew { } } What is the problem and how do I fix that? Can anyone tell me? Sorry for my English. Im not a mother tongue.
best swift course on youtube currently
I am convinced Nick is the nicest person on earth, and/or struck it big with some dream job as a mobile dev, because MY GOD. This content is amazing. I am hoping there is more content from you after this basics course :) If not, I will be reading the entire Swift Textbook next.
You’re on course 1 of 13 🤙
Watch order is here: www.swiftful-thinking.com/store
the best explanation of swift ever
Thanks very much for these well expressed lessons!
It took me three days to get through the optionals as I could only deal with so much info inside of a couple hours. I'll likely forget half of what I learned, but at least there'll be bits of info that will service as hints going forth.
There's a bit of confusion introduced in the last bit on chaining optionals.
It's generally better to create copies of code blocks you're going to alter to illustrate concepts than returning to previous blocks and doing so. Each block the user creates (with commentary) is better left unedited avoiding typos and missed aspects like for instance the ?. I don't how others learn, but I need to follow along and type code to reinforce the info being conveyed. I'm also a lousy typist so I often get frustrated and lost....
But anyway - again - thanks very much Nick!
Optionals confused the hell out of me until this video. The examples showing distinctions between guard let of all three vars vs. layered guard was especially helpful. Thanks so much!
I liked this video. Deeper down into unwrapping optionals compared to other videos out there. Thanks.
love it man. You are such a gem. Thanks nick.
8:55
need to explain what ".description" do => gets you the value of "non-String variable" into a String value , so you can actually do "coalescing operator" and print a "string" value inside \( ) out of "Bool => non String dataType".
not and easy topic but i trust it will be important in the future, thanks for making such a detail explanation, I did some test printing things before and after unwrap and also the explicit of a nil to see it crash, it helped me understand a bit more.
Thank you, Nick, excellent tutorial I look forward to learning more about writing cleaner Swift code Keep up the great tutorials!
A lot of information together but omg so useful! Thank you so much! Loved the video!
Wow...nice job on the explanation on optionals!
I know you’ve already completed the other playlists and know this already 😂 thanks though!
The videos get longer throughout the playlist! I really appreciate the content, thanks!
So do the lines of code for me... It went from 20 --> 200 in a few videos :)
awesome channel!
Tremendous work💪 and very easy to follow🛵
Thanks a lot!
Thanks!
I understand optionals better now. Thanks a bunch
Большое спасибо! Очень крутое объяснение!
Thanks, Nick, great explanation...
I have seen in many articles, there is one more approach to unwrapped.
let optional: String? = "I love Swift"
if case let unwrapped? = optional {
print(unwrapped)
}
is it the correct way?(for such a case)
these are best swift courses , no words to express my gratitudes
Thank you!! These comments help 🙏
Awesome! I have an idea for a calculation type app. The user would need to enter some values (how do convert a string to a double?) but of course when the app first opens there aren’t any values. Do these variables need to be optionals or can they be nil?
Why doesn't my Xcode have a warning prompt? How can I turn it on? My Xcode version is 15.2
Man this video is amazing, you broke this down very well and simple. I been trying to understand optionals for a while, esp the guard statement, but with more practice, I think I understand the concept. Thank you
Nick, thanks so much for this one! Unwrapping and the use of guard was a gray area for me. You make it so easy to understand! Keep up the great work my friend!
Is there any way to help us visualize (via the console) functions "checkIfUserIsPremium" 1-6? It's quite confusing keeping the different constants and function names separated and understanding how each function works without seeing some final product.
I want source code of all your examples, How can i download it or pls share path
GitHub @SwiftfulThinking
Very very good optionals tutorial. I loved all the examples! Thank you!
thankyou Nick,
For Non SwitData, objects above work well,
but it seems if the object is from SwitData, no way i can delete optional input, for example :
let input_ClientMst:ClientMst? // received from another view & i am checking for not nil
...
if(input_ClientMst != nil)
{
modelContext.delete(input_ClientMst)
}
error Value of optional type 'ClientMst?' must be unwrapped to a value of type 'ClientMst'
hope you can guide me , how to unwarp
how to show declaration when we click on the variable?
option+ press your mouse
How did you comment more lines at once ?
you can use
/* line1
line2
line3 */
else use command+/ (selecting multiple lines to comment)
Absolutely love the series, I have been getting bug messages from xcode, just by copying everything that he has written,"Main actor-isolated var 'userIsPremium' can not be referenced from a nonisolated context" if anybody can help explain I would really appreciate it
If you’re building this in Xcode, the new versions of Xcode run Swift 6, which is a more strict compiler. You can turn this off by going to the project navigator, clicking “Build Settings”, search for Swift Language Version, and revert it down to Swift 5.
The warning is telling you that pieces of code can only be accessed on the “MainActor” which is the default thread where most of your code runs anyway. With the new Swift 6 compiler, we are now forced to explicitly tell the compiler if we’re are on the MainActor. This can usually be solved by just putting “@MainActor” before the “func”, “var”, “let”, “class” or other keywords.
The MainActor is a more advanced topic that I cover in the Swift Concurrency playlist, but not something I would worry much about just yet!
I am experiencing the same error, so you're not alone. I have not yet found a solution.
@@SwiftfulThinking I'm not able to switch to Swift 5 in the playground. How do I find the settings for this?
@@CDsCartoonsim not sure you can change the compiler in Playgrounds. If you but “@MainActor” before the function it should work
Great Playlist, The best way to learn Swift! i love your video. Thank you!!
Its providing me error when I am writing the optional code. Error - main actor-isolated var 'userIsNew' can not be referenced from a nonisolated context
guard let userIsNew, let userDidOnboarding, let userFavouriteMovie else{
Is it because swift of the swift version because. it was working in the video
Edit : got the answer , it is due to the swift version 6.0 . Swift came with the upgrade of complete concurrency checking is enabled by default. you have to add Main Actor annotation to make it work
Just put @MainActor before your function declarations and it should go away
@SwiftfulThinking could you please elaborate why we have to add Main Actor before my function declaration, i know its an update but can you please explain what it really does
I always get error "Variable binding in a condition requires an initializer" if I refactor the `if let isNew = userIsNew` to `if let isNew` . ChatGTP says that I need to keep the first version so how come it doesn't work? I ran `xcrun swift -version` on my terminal and it says `swift-driver version: 1.45.2 Apple Swift version 5.6.1`. Is the version too old to work with this new syntax you use?
I'm able to follow the code. But I don't fundamentally understand why I would ever use an optional? What is the benefit of it over a non-optional? Why do I want to have variables that are null? Wouldn't I just rather have a boolean with a default of false, an integer with a default of 0, or a string with a fault of empty?
There are times where we can use default values to avoid optionals, but providing a default value is not the same as not having a value.
Imagine fetching the user’s age that fails. You could have a default age of 0 or leave it as optional.
If it’s optional, you can unwrap it to check that there is an age.
If it’s defaulted to 0, it would appear no different than successful. You’d likely need extra logic to confirm it’s not the defaulted value.
But high level optionals are fundamentally build into Swift. As you start to build apps you’ll realize it’s a net positive for you as the developer. It’s not a question of “why would I want this” but “how can I handle this” 😅
@@SwiftfulThinking Thanks so much for the further explanation. That "age check" is a nice example. Overall, I'm really enjoying your videos. I have a simple appthat I intend to build when I finish the lessons and I'm sure some of these things (like optionals) that don't seem that important now, will make more sense when I start coding the app.
Awesome Man Awesome!!!!!!!🤓
Excellent tutorial!
Thanks!
Thank you Nik. Great info!!!
Thanks!
I've got a question for when I try to access variables in a function. E.g. in this code:
var userIsNew: Bool? = true
func checkIfUserIsSetup() {
if let isNew = userIsNew {
}
}
The Compiler always tells me to add @MainActor before the "func". So when I press on fix the code I end up with this code:
var userIsNew: Bool? = true
@MainActor func checkIfUserIsSetup() {
if let isNew = userIsNew {
}
}
What is the problem and how do I fix that? Can anyone tell me?
Sorry for my English. Im not a mother tongue.
I have the same problem... please help! I'm stuck and can't seem to move on
Same here , i dont know if its my mistake or we have to mention main actor in the code
i've watched this vid twice and still don't get it. gonna read the dev book further and come back to this vid later.
"Very Nice!"
Hi Nick. Did someone else record this part? When you started the coding section and suddenly your voice was changed. This was not your voice.
good stuff
Wow... great work. Thank you.
Excellent explanation.
it gets better and better
Hi Nick 🤩
Helllllooooooooo
'nil requires a contextual type
"promosm" 😭