SwiftUI ViewBuilder is resultBuilder, and from Swift 5.3 you can declare if let, if case, multiple if statements, switch, ... pretty much like a normal block function.
ViewBuilder is recommended to leverage SwiftUI type system to ensure performance. Here are a few examples 👇
Local variables.
Pretty much like a normal function, you can declare local variables and return View at last.
Mix if and switch statements
This is handy when you want to show modal or overlay of different Views
If statement only.
No more if else with EmptyView, you can just return View for the happy path.
Empty return.
For function marked with ViewBuilder, you don't need to return anything
Return nil.
Optional conforms to SwiftUI View as long as its Wrapped conforms to View. So we can return nil from ViewBuilder
• • •
Missing some Tweet in this thread? You can try to
force a refresh
Convert JSON into gorgeous, typesafe code in any language. I use this a lot to quickly generate Swift models from server JSON response. It generates very elegant enum handling and optiona
Besides coming up with a good idea and building the app, there are many other things you can do to boost your apps' visibility #iosdev
Thread 👇
🧑🎨 Apple Human Interface Guidelines
HIG provides in-depth information and resources to design great apps. Not only you learn the fundamental of colors and fonts, you also learn how elements are used in Apple own apps as best practices
My most favorite session every WWDC is watching Apple Design Award. Learn how awesome apps demo design, innovation, and technology on Apple platforms, and why @Apple decide they deserve the price
I've done some #SwiftUI lately for @pushheroapp@PastePalApp , and amazed by how easy and fun it is to make apps. If you want to get into SwiftUI but don't know where to start, here are my recommended resources #iosdev
Thread 👇
1) First thing first is @Apple official guides. Apple has done a stunning job to make SwiftUI tutorials fun and interactive
1) Core Data is more than just SQLite wrapper, it manages objects, relationships, fetching, faulting, ...
2) Having 2 context: 1 main and 1 background that are both backed by the persistent coordinator. In modern Core Data stack, NSPersistentContainer has default viewContext already, we just need another newBackgroundContext
1) Scratch your own itch. If you don't have any itch to scratch, stop here. This is awkward. Go travelling. Go exploring the world. The world always has problems and needs solution.
2) Build any service, app or website. Along the way you'll find tons of things you need that and unsolved by existing solutions, and tons of things you can improve upon.
3) Sign up for some paid newsletters to find ideas. This is the worst. This is like someone browsing through a tatoo catalog. You're doing things for trend, for money, not for your self drive 👎