swiftPunk
swiftPunk

Reputation: 1

When to use SwiftUI Interface with UIKit Life Cycle?

I like to know why we should create and use a SwiftUI Interface with UIKit Life Cycle? I get confused about it! Because:

1-if you want UIKit programming then go and choose Storyboard for Interface and then choose UIKit for Life Cycle.

2-if you want SwiftUI programming then go and choose SwiftUI for Interface and then choose SwiftUI for Life Cycle.

3-if you want change your Swift Language then go change it to Objective-C and you will get Storyboard as Interface and UIKit as Life Cycle.

Here comes Option 4:

4- You can have SwiftUI for Interface and UIKit as life Cycle! which is the Topic of this Question! If I am not wrong SwiftUI handle things different than UIKit, we do not need define delegate or protocols in SwiftUI or things like that, but why we get AppDelegate and SceneDelegate in this case! what is pros and cons in case we create such a Xcode project?

Upvotes: 5

Views: 2826

Answers (1)

pawello2222
pawello2222

Reputation: 54516

With SwiftUI you should in most cases use SwiftUI lifecycle.

If you need some AppDelegate methods you can use @UIApplicationDelegateAdaptor:

There are some cases, however, when you need UIKit lifecycle:

Upvotes: 7

Related Questions