extension UIApplication {
override open var next: UIResponder? {
print("next")
return super.next
}
}
上面的代码是在iOS 13.4之前执行的,在方法next
之前打印了“ ”application(_:, didFinishLaunchingWithOptions:)
在iOS 13.4和最新的iOS 13.4.1上,控制台不输出next
。如果我print()
在行上断了断点,断点将不会被执行
这导致我以前的一些代码失败,例如:
import UIKit
public extension UIApplication {
private static let runOnce: Void = {
NothingToSeeHere.harmlessFunction()
}()
override var next: UIResponder? {
// Called before applicationDidFinishLaunching
UIApplication.runOnce
return super.next
}
}
public protocol SelfAware: class {
static func awake()
}
public class NothingToSeeHere {
public static func harmlessFunction() {
let typeCount = Int(objc_getClassList(nil, 0))
let types = UnsafeMutablePointer<AnyClass>.allocate(capacity: typeCount)
let autoreleasingTypes = AutoreleasingUnsafeMutablePointer<AnyClass>(types)
objc_getClassList(autoreleasingTypes, Int32(typeCount))
for index in 0 ..< typeCount {
(types[index] as? SelfAware.Type)?.awake()
}
types.deallocate()
}
}
为什么会这样?这是 iOS 13.4 中的错误吗?还是特色?我在 iOS 13.4 的发行说明中没有找到任何相关内容...
让我列出我测试的情况:
- 13.2 iPhone、
next
方法执行和之前application(_:, didFinishLaunchingWithOptions:)
的 . - 13.3 模拟器、
next
方法执行和之前application(_:, didFinishLaunchingWithOptions:)
的 . - 13.4 模拟器,
next
方法未执行。 - 13.4 iPhone,
next
方法未执行。 - 13.4.1 iPhone,
next
方法未执行。