0xSina
0xSina

Reputation: 21553

UIViewController initialization in Swift

I am trying to initialize a subclass of UIViewController that has a corresponding .xib file.

I do it via:

LandingVC()

However, this doesn't initliaze it with the xib file. I have to do it manually via:

LandingVC(nibName: "LandingVC", bundle: nil)

What I am confused about is that in Objective-C, I could do this:

[[LandingVC alloc] init]

and it would automaitcally infer the xib name (if it exists). Why doesn't this work in Swift?

Thanks

Upvotes: 4

Views: 1172

Answers (1)

rshev
rshev

Reputation: 4176

To instantiate a View Controller with automatically loading .xib in swift name your xib file as Module name.Class name.xib

It was mentioned in Apple documentation.

Upvotes: 3

Related Questions