有时会遇到重写 Main 函数来使用不同的 AppDelegate 或 UIApplication 子类的需求, 这里就来看在 Xcode 10 之后 Main 函数的写法.
直接上代码:
swift
import UIKit let argv = UnsafeMutableRawPointer(CommandLine.unsafeArgv) .bindMemory(to: UnsafeMutablePointer<Int8>?.self, capacity: Int(CommandLine.argc)) _ = UIApplicationMain( CommandLine.argc, argv, NSStringFromClass(UIApplication.self), NSStringFromClass(AppDelegate.self) )