r/iOSProgramming • u/soulchild_ Objective-C / Swift • Jun 23 '19
SwiftUI vs UIKit – Comparison of building the same app in each framework
https://www.youtube.com/watch?v=qk2y-TiLDZo9
Jun 24 '19
I have a gut feeling that SwiftUI will be great for simple things but some of the really complex stuff I've been asked to build in the past is going to look like legacy perl by the time I'm done.
I don't think it will scale.
4
u/chrabeusz Jun 24 '19
Because it looks simple, it doesn't mean it simple. A View can contain tremendous amount of complexity, it's just encapsulated inside a tiny struct.
EDIT: but it's true that Apple didn't show more advanced stuff. If we could check the source code of NavigationButton we could learn how to push pages, but sadly SwiftUI is not open.
1
u/ThePantsThief NSModerator Jun 24 '19
I have yet to see a SwiftUI example that handles network API errors well, but I'm sure it's possible. Do you know of any?
1
u/chrabeusz Jun 24 '19
I'm not sure if anything else exists, so I just copied my usual approach: https://github.com/szotp/SwiftUI_loading_and_errors/blob/master/ErrorHandling/ContentView.swift
AsyncButton executes a method and shows alert if it fails.
AsyncDisplay shows data or error inline (alerts are annoying so I leave them for actions that user initiated, like pressing a button).
Both views also display loading indicators and allow user to try again if error happens.
1
8
u/XunlaY Jun 23 '19
That's a nice comparison. I would like to see such a comparisonn between Interface Builder + UIKit vs SwiftUI.
10
u/twostraws Hacking with Swift Jun 24 '19
Yeah, this felt a bit like a no-win situation – if I had gone through IB I would have had people complaining that I should have used code, etc. I figured at least we could look at the code side by side and eliminate variables like "which one is better in source control?" etc.
1
-6
Jun 24 '19
Don't feel like watching this simply because the ui is too simple to get a feel of how swiftui stacks up against uikit
23
u/soulchild_ Objective-C / Swift Jun 23 '19
An interesting comparison by /u/twostraws! He highlighted parts where SwiftUI is a lot faster (loading JSON in preview, setting stackview constraints etc)