Clement Prem
Clement Prem

Reputation: 3119

Initialising swift view controller with nib name in objc class

In my app I have a view controller written in Swift. I imported it in to app delegate which is written in objective c. I try to create an object of the swift view controller like this

ListAllSongsViewController *songListVC = [[ListAllSongsViewController alloc]initWithNibName:@"ListAllSongsViewController" bundle:nil];

The ListAllSongsViewController is written in swift. The project compile without any issue but when executing the above line the app crashes & stops at init method of ListAllSongsViewController

The crash

There is nothing in the log, it just stops. Zombie & All exception break points are enabled.

P.S. It only crashes in device (iOS 7.1), but works fine in simulator

Update : Getting the same issue even if I use the default swift initialiser

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

Upvotes: 1

Views: 2553

Answers (1)

Louis Zhu
Louis Zhu

Reputation: 802

Usually occurs when you passed a wrong nibName. Considering it crashes only in device, I think you've made a mistake about the case of the string ListAllSongs, because the Mac/Simulator's file system is case insensitive while the device is not.

Upvotes: 1

Related Questions