我在真正的Apple Watch(watchOS 2.0.1)
上启动了XCode 7.1.1的应用程序我的ExtensionDelegate中的一些代码:
var applicationDidFinishLaunchingCalled = 0
func applicationDidFinishLaunching() {
applicationDidFinishLaunchingCalled++
print("applicationDidFinishLaunching() round \(applicationDidFinishLaunchingCalled)")
}
var applicationDidBecomeActiveCalled = 0
func applicationDidBecomeActive() {
applicationDidBecomeActiveCalled++
print("applicationDidBecomeActive() round \(applicationDidBecomeActiveCalled)")
}
var applicationWillResignActiveCalled = 0
func applicationWillResignActive() {
applicationWillResignActiveCalled++
print("applicationWillResignActive() round \(applicationWillResignActiveCalled)")
}
将以下内容输出到控制台:
applicationDidFinishLaunching() round 1
applicationDidBecomeActive() round 1
applicationDidFinishLaunching() round 2
applicationDidBecomeActive() round 2
(没有调用applicationWillResignActive())
这里发生了什么? 如何防止应用程序初始化两次? 当我没有调试时,我如何知道这不会发生?
我在一次调用所有内容的模拟器中没有这种效果。