Skip to content

Commit 98ed7f3

Browse files
committed
Minor iOS changes
1 parent ed75d0f commit 98ed7f3

File tree

5 files changed

+34
-36
lines changed

5 files changed

+34
-36
lines changed

Chapter 14/MyProjectClient/iOS/Sources/AppDelegate.swift

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,22 @@
99
import UIKit
1010

1111
@UIApplicationMain
12-
class AppDelegate: UIResponder, UIApplicationDelegate {
12+
class AppDelegate: UIResponder {
13+
14+
}
1315

14-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
15-
16+
extension AppDelegate: UIApplicationDelegate {
17+
18+
func application(_ application: UIApplication,
19+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1620
return true
1721
}
18-
19-
// MARK: UISceneSession Lifecycle
20-
21-
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
22-
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
22+
23+
func application(_ application: UIApplication,
24+
configurationForConnecting connectingSceneSession: UISceneSession,
25+
options: UIScene.ConnectionOptions) -> UISceneConfiguration {
26+
return .init(name: "Default Configuration",
27+
sessionRole: connectingSceneSession.role)
2328
}
24-
25-
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
26-
27-
}
28-
29-
3029
}
3130

Chapter 14/MyProjectClient/iOS/Sources/Modules/App.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,14 @@ final class App {
1414
let services: ServiceBuilderInterface
1515
let modules: ModuleBuilderInterface
1616

17-
// MARK: - singleton
18-
1917
static let shared = App()
2018

2119
private init() {
22-
// do nothing...
23-
2420
self.services = ServiceBuilder()
2521
self.modules = ModuleBuilder()
2622
}
2723

28-
// MARK: - api
29-
3024
func setup() {
3125
self.services.setup()
3226
}
33-
3427
}

Chapter 14/MyProjectClient/iOS/Sources/Modules/Root/RootInteractor.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ extension RootInteractor: RootInteractorPresenterInterface {
2020
self.services.api.getBlogPosts()
2121
.map { page -> RootEntity in
2222
let domain = "http://localhost:8080"
23-
return .init(items: page.items.map { .init(id: $0.id,
24-
title: $0.title,
25-
imageUrl: URL(string: domain + $0.image)!,
26-
url: URL(string: domain + "/" + $0.slug)!) })
23+
return .init(items: page.items.map {
24+
.init(id: $0.id,
25+
title: $0.title,
26+
imageUrl: URL(string: domain + $0.image)!,
27+
url: URL(string: domain + "/" + $0.slug)!)
28+
29+
})
2730
}
2831
.mapError { $0 as Error }
2932
.eraseToAnyPublisher()

Chapter 14/MyProjectClient/iOS/Sources/SceneDelegate.swift

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,26 @@
88

99
import UIKit
1010

11-
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
12-
11+
class SceneDelegate: UIResponder {
12+
1313
var window: UIWindow?
14+
}
1415

16+
extension SceneDelegate: UIWindowSceneDelegate {
17+
1518
func scene(_ scene: UIScene,
1619
willConnectTo session: UISceneSession,
1720
options connectionOptions: UIScene.ConnectionOptions)
1821
{
19-
if let windowScene = scene as? UIWindowScene {
20-
let window = UIWindow(windowScene: windowScene)
21-
let rootView = App.shared.modules.root()
22-
let rootVC = UINavigationController(rootViewController: rootView)
23-
window.rootViewController = rootVC
24-
self.window = window
25-
window.makeKeyAndVisible()
22+
guard let windowScene = scene as? UIWindowScene else {
23+
return
2624
}
25+
let window = UIWindow(windowScene: windowScene)
26+
let rootView = App.shared.modules.root()
27+
let rootVC = UINavigationController(rootViewController: rootView)
28+
window.rootViewController = rootVC
29+
self.window = window
30+
window.makeKeyAndVisible()
2731
}
28-
2932
}
3033

Chapter 14/MyProjectClient/iOS/Sources/ServiceInterface.swift renamed to Chapter 14/MyProjectClient/iOS/Sources/Services/ServiceInterface.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ protocol ServiceInterface: class {
1515
extension ServiceInterface {
1616

1717
func setup() {
18-
// do nothing...
18+
1919
}
2020
}

0 commit comments

Comments
 (0)