I am reading a book related to IOS development. And i am facing a problem when i reading this line let bundle = NSBundle.mainBundle()
. The book told that
this call returns a bundle object that represents our application.
I know, in swift an object is created as let objname = classname()
. Please tell how let bundle = NSBundle.mainBundle()
create an object?
This call does not create (instanciate) a new object. It calls the
mainBundle
class method on theNSBundle
class, which returns a singleton, the main bundle of your app.Similar calls (in obj-C, but translatable in Swift easily):
[UIApplication sharedApplication]
[NSNotificationCenter defautCenter]