Skip to content
This repository was archived by the owner on May 17, 2023. It is now read-only.

Commit e63e5c2

Browse files
Update 09_Creating_the_iOS_application.md
1 parent 941054d commit e63e5c2

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

Networking and Data Storage with Kotlin Multiplatfrom Mobile/09_Creating_the_iOS_application.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -149,30 +149,22 @@ Also, we marked the `getLaunches` function with the `@Throws(Exception::class)`
149149
}
150150
```
151151

152-
Now for the last step: let's go to the `SceneDelegate.swift`, initialize our SDK, view, and view model, and make it work!
152+
Now for the last step: let's go to the entry point off our app `iOSApp.swift`, initialize our SDK, view, and view model, and make it work!
153153

154154
```swift
155-
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
156-
157-
var window: UIWindow?
155+
import SwiftUI
156+
import shared
158157

158+
@main
159+
struct iOSApp: App {
159160
let sdk = SpaceXSDK(databaseDriverFactory: DatabaseDriverFactory())
160-
161-
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
162-
163-
let contentView = ContentView(viewModel: .init(sdk: sdk))
164-
165-
// Use a UIHostingController as window root view controller.
166-
if let windowScene = scene as? UIWindowScene {
167-
let window = UIWindow(windowScene: windowScene)
168-
window.rootViewController = UIHostingController(rootView: contentView)
169-
self.window = window
170-
window.makeKeyAndVisible()
161+
var body: some Scene {
162+
WindowGroup {
163+
ContentView(viewModel: .init(sdk: sdk))
171164
}
172165
}
173-
174-
// ...
175166
}
167+
176168
```
177169

178170
All done! Press the run button and see the result:

0 commit comments

Comments
 (0)