1

I'm a cocoa and Objective-c newbie. I'm trying to build a mac app, and when I try to create a new controller which inherits from NSViewController, it automatically gives me a - (void)viewDidLoad in the .m file (but not in the .h). The problem is that the compiler always yells saying "No visible @interface for 'NSViewContoller' declares the selector 'viewDidLoad'.

How is this possible? Please help me understand what is happening here and how I can fix it. Thank you.

AyushISM
  • 381
  • 7
  • 21

2 Answers2

5

ViewDidLoad is only supported in NSViewController if you target OSX Yosemite and upwards ! Remove it if you are targeting below Yosemite for your app and use -awakeFromNib or -loadView method instead.

As you can see it in Apple's NSViewController Reference that it is

Available in OS X v10.10 and later.

P.S This happened to me while developing an app for OSX Mevericks and above when I inherited a class from NSViewController and Xcode 6 automatically generated ViewDidLoad method for me which is actually a bug (I Think)

Nofel Mahmood
  • 898
  • 7
  • 12
-2

From documentation of apple, method NSViewDidLoad:

"For a view controller originating in a nib file, this method is called immediately after the view property is set. For a view controller created programmatically, this method is called immediately after the loadView method completes."

You need create a method in .h for view in your app.

Vaibhav B.
  • 11
  • 3