There is no main()
method in swift. The program must start the execution from somewhere. So what is the entry point of swift code execution and how is it decided?
相关问题
- “Zero out” sensitive String data in Swift
- SwiftUI: UIImage (QRCode) does not load after call
- Get the NSRange for the visible text after scroll
- UIPanGestureRecognizer is not working in iOS 13
- What does a Firebase observer actually do?
相关文章
- Using if let syntax in switch statement
- Xcode: Is there a way to change line spacing (UI L
- Enum with associated value conforming to CaseItera
- Swift - hide pickerView after value selected
- Is there a Github markdown language identifier for
- How can I vertically align my status bar item text
- Adding TapGestureRecognizer to UILabel in Swift
- Attempt to present UIAlertController on View Contr
In the
AppDelegate.swift
file you can see@UIApplicationMain
.The AppDelegate is the initial entry file.
Basically:
main.m
andAppDelegate.m
are kinda merged inSwift
to justAppDelegate.swift
The entry point in a plain Swift module is the file in the module called
main.swift
.main.swift
is the only file which is allowed to have expressions and statements at the top level (all other Swift files in the module can only contain declarations).Cocoa Touch uses the
@UIApplicationMain
attribute on an implementation ofUIApplicationDelegate
instead of amain.swift
file to mark the entry point. Cocoa used to use a minimalmain.swift
file which simply calledNSApplicationMain
, but as of Xcode 6.1 uses the@NSApplicationMain
attribute on an implementation ofNSApplicationDelegate
.You may want to read Files and Initialization