Never Type in SwiftUI: Exploring its Role in Creating Primitive Views

Опубликовано: 04 Июнь 2021
на канале: Swift and Tips
1,270
65

Hello guys, Welcome to another video. Today we will explore Never type in Swift. Never is great to represent things that literally will never happen, but also to stop the execution of an application in case something really bad just happened.

However, that’s not all, Never is a vital piece to build SwiftUI Framework. Let’s see how SwiftUI uses Never to avoid infinite loops reviewing subviews in body property.

Let's get started 😉!

Content:
0:00 - Intro
1:08 - Every function must return a type
4:00 - Never to stop the execution
7:14 - Cases that will never happen
12:06 - Never in SwiftUI
16:43 - Can we create custom views with Never?
18:38 - Summary
19:55 - Outro

------
References:
NSHipster: https://nshipster.com/never/
Never proposal: https://github.com/apple/swift-evolut...
How never internally works?: https://swiftrocks.com/how-never-work...
Impossible views: https://www.fivestars.blog/articles/i...


Source code showed in the video:
https://github.com/pitt500/swift-and-...

------
Other videos in the channel:
State management in SwiftUI:    • State Management in SwiftUI  
UIKit in SwiftUI:    • UIKit in SwiftUI  
Generics:    • Generics  
The power of Combine:    • The power of Combine  

-----
Don't forget to subscribe to the channel, like it, and follow me on social media:

Twitter:
  / swiftandtips  
  / pitt500  

Finally, ask me for a video you would like to see next 😄!

Credits:
Music by Wataboi from https://pixabay.com/
Video edited with LumaFusion


Смотрите видео Never Type in SwiftUI: Exploring its Role in Creating Primitive Views онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Swift and Tips 04 Июнь 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 1,270 раз и оно понравилось 65 людям.