What is the difference between [NSObject: AnyObject] and AnyObject in swift

In the default template, we can find the following code:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool

Just wondering why here [NSObject: AnyObject]? not AnyObject? What is the difference between the two?

+4
source share
1 answer

[NSObject: AnyObject]- A dictionary that allows you to access one object by providing another object. Simple placement AnyObjectmeans that your program does not know if the parameter is a dictionary, string, or int, or what, and therefore does not know how to handle it. In addition, the OS calls this method, so you know what you get each time [NSObject: AnyObject], so why not specify the type of parameter.

+1
source

All Articles