In default template we can find the following code:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
Just wonder why here it is [NSObject: AnyObject]? rather than AnyObject? What's the different between them?
[NSObject: AnyObject]
is a dictionary that allows you to access one object by providing a different object. Simply putting AnyObject
means that your program doesn't know whether the parameter is a dictionary, a string, and int, or what, and therefore doesn't know how to handle it. Besides, the OS calls that method so you know you are getting a [NSObject: AnyObject]
every time, so why not have the parameter type that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.