Skip to content

Commit 46e5e0a

Browse files
committed
SceneDelegate.swiftの新規追加対応
1 parent 5696064 commit 46e5e0a

File tree

4 files changed

+82
-21
lines changed

4 files changed

+82
-21
lines changed

handMadeCalendarAdvance.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
DE7397041CCB4EC100A9A222 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DE7397021CCB4EC100A9A222 /* LaunchScreen.storyboard */; };
2222
DE73970F1CCB4EC100A9A222 /* handMadeCalendarAdvanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE73970E1CCB4EC100A9A222 /* handMadeCalendarAdvanceTests.swift */; };
2323
DE73971A1CCB4EC100A9A222 /* handMadeCalendarAdvanceUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE7397191CCB4EC100A9A222 /* handMadeCalendarAdvanceUITests.swift */; };
24+
DE7609502F05DFBF005D8CC2 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE76094F2F05DFBF005D8CC2 /* SceneDelegate.swift */; };
2425
DEE369B4257C8A1600A22800 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEE369B3257C8A1600A22800 /* MainViewController.swift */; };
2526
DEE369C3257C8E5A00A22800 /* DatePickerCalendarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEE369C2257C8E5A00A22800 /* DatePickerCalendarViewController.swift */; };
2627
DEE369D1257CCD3400A22800 /* DisplayDateTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEE369D0257CCD3400A22800 /* DisplayDateTextField.swift */; };
@@ -110,6 +111,7 @@
110111
DE7397151CCB4EC100A9A222 /* handMadeCalendarAdvanceUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = handMadeCalendarAdvanceUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
111112
DE7397191CCB4EC100A9A222 /* handMadeCalendarAdvanceUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = handMadeCalendarAdvanceUITests.swift; sourceTree = "<group>"; };
112113
DE73971B1CCB4EC100A9A222 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
114+
DE76094F2F05DFBF005D8CC2 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
113115
DEE369B3257C8A1600A22800 /* MainViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = "<group>"; };
114116
DEE369C2257C8E5A00A22800 /* DatePickerCalendarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatePickerCalendarViewController.swift; sourceTree = "<group>"; };
115117
DEE369D0257CCD3400A22800 /* DisplayDateTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplayDateTextField.swift; sourceTree = "<group>"; };
@@ -220,6 +222,7 @@
220222
DE0166BA1CDE40DC002BB133 /* Component */,
221223
DEE369BB257C8B5600A22800 /* ViewController */,
222224
DE7396F91CCB4EC100A9A222 /* AppDelegate.swift */,
225+
DE76094F2F05DFBF005D8CC2 /* SceneDelegate.swift */,
223226
DE7396FD1CCB4EC100A9A222 /* Main.storyboard */,
224227
DE7397001CCB4EC100A9A222 /* Assets.xcassets */,
225228
DE7397021CCB4EC100A9A222 /* LaunchScreen.storyboard */,
@@ -618,6 +621,7 @@
618621
files = (
619622
DEE369D1257CCD3400A22800 /* DisplayDateTextField.swift in Sources */,
620623
DEE369C3257C8E5A00A22800 /* DatePickerCalendarViewController.swift in Sources */,
624+
DE7609502F05DFBF005D8CC2 /* SceneDelegate.swift in Sources */,
621625
DE03CFF329608C650054BCF1 /* NewCalendarViewController.swift in Sources */,
622626
DE7396FC1CCB4EC100A9A222 /* MonthlyCalendarViewController.swift in Sources */,
623627
DE4977542D26609200FEC950 /* DatePickerSelectView.swift in Sources */,

handMadeCalendarAdvance/AppDelegate.swift

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,24 @@ import UIKit
1111
@UIApplicationMain
1212
class AppDelegate: UIResponder, UIApplicationDelegate {
1313

14-
var window: UIWindow?
15-
16-
1714
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1815
// Override point for customization after application launch.
1916
return true
2017
}
2118

22-
func applicationWillResignActive(_ application: UIApplication) {
23-
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
24-
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
25-
}
26-
27-
func applicationDidEnterBackground(_ application: UIApplication) {
28-
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
29-
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30-
}
31-
32-
func applicationWillEnterForeground(_ application: UIApplication) {
33-
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
34-
}
19+
// MARK: UISceneSession Lifecycle
3520

36-
func applicationDidBecomeActive(_ application: UIApplication) {
37-
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
21+
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
22+
// Called when a new scene session is being created.
23+
// Use this method to select a configuration to create the new scene with.
24+
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
3825
}
3926

40-
func applicationWillTerminate(_ application: UIApplication) {
41-
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
27+
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
28+
// Called when the user discards a scene session.
29+
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
30+
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
4231
}
4332

44-
4533
}
4634

handMadeCalendarAdvance/Info.plist

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,24 @@
3434
<array>
3535
<string>UIInterfaceOrientationPortrait</string>
3636
</array>
37+
<key>UIApplicationSceneManifest</key>
38+
<dict>
39+
<key>UIApplicationSupportsMultipleScenes</key>
40+
<false/>
41+
<key>UISceneConfigurations</key>
42+
<dict>
43+
<key>UIWindowSceneSessionRoleApplication</key>
44+
<array>
45+
<dict>
46+
<key>UISceneConfigurationName</key>
47+
<string>Default Configuration</string>
48+
<key>UISceneDelegateClassName</key>
49+
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
50+
<key>UISceneStoryboardFile</key>
51+
<string>Main</string>
52+
</dict>
53+
</array>
54+
</dict>
55+
</dict>
3756
</dict>
3857
</plist>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//
2+
// SceneDelegate.swift
3+
// handMadeCalendarAdvance
4+
//
5+
// Created by 酒井文也 on 2026/01/01.
6+
// Copyright © 2026年 just1factory. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
12+
13+
var window: UIWindow?
14+
15+
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
16+
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
17+
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
18+
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
19+
guard let _ = (scene as? UIWindowScene) else { return }
20+
}
21+
22+
func sceneDidDisconnect(_ scene: UIScene) {
23+
// Called as the scene is being released by the system.
24+
// This occurs shortly after the scene enters the background, or when its session is discarded.
25+
// Release any resources associated with this scene that can be re-created the next time the scene connects.
26+
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
27+
}
28+
29+
func sceneDidBecomeActive(_ scene: UIScene) {
30+
// Called when the scene has moved from an inactive state to an active state.
31+
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
32+
}
33+
34+
func sceneWillResignActive(_ scene: UIScene) {
35+
// Called when the scene will move from an active state to an inactive state.
36+
// This may occur due to temporary interruptions (ex. an incoming phone call).
37+
}
38+
39+
func sceneWillEnterForeground(_ scene: UIScene) {
40+
// Called as the scene transitions from the background to the foreground.
41+
// Use this method to undo the changes made on entering the background.
42+
}
43+
44+
func sceneDidEnterBackground(_ scene: UIScene) {
45+
// Called as the scene transitions from the foreground to the background.
46+
// Use this method to save data, release shared resources, and store enough scene-specific state information
47+
// to restore the scene back to its current state.
48+
}
49+
50+
}

0 commit comments

Comments
 (0)