I have been stuck with this warning for several hours now. I've looked around SO for answers, attempted all the ones I found and couldn't find the solution. Here's the run-down of the code I have, which Xcode generated by default.
This is in my AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
I have this on main.m (according to this answer)
int main(int argc, char *argv[])
{
@autoreleasepool {
int retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
return retVal;
}
}
I also have all the connections in my MainWindow.xib connected correctly. So I'm at a loss right now. Anything that I could be missing? Thanks in advance!
You can open xib file and right-click "File's Owner" in Placeholders. If view didn't connect to View outlet then hold "Ctrl" key and drag right mouse click to design, then run again ^^ (do not drag to particular control, drag to background design when appear border View).
I have solve issue in my project, Follow the below steps to solve it..
1) Open the main view controller nib file, that file you have reference in
appDelegate
eg.ViewCotroller.xib2) On nib file check the view connection, if not connected to file owner then connect it.
3) Now run the project.
I have this message because I had in my RootViewController @property(weak, nonatomic) IBOutlet UIView* loadView; and viewDidLoad was called twice... Rename it to something else...
It's odd to be setting your window's
rootViewController
inapplication:didFinishLaunchingWithOptions:
if you have aMainWindow.xib
. Usually a project follows one of three templates:Some projects have a
MainWindow.xib
. The target's “Main Interface” is set to “MainWindow” in the target's Summary tab (or in its Info.plist). This xib's File's Owner isUIApplication
. The xib contains an instance ofAppDelegate
, connected to the File's Owner'sdelegate
outlet. The xib also contains aUIWindow
, whoserootViewController
outlet is connected to aUIViewController
(or subclass, such asUINavigationController
), which is also in the xib. By the time the application delegate receives theapplication:didFinishLaunchingWithOptions:
message, the xib is entirely loaded, so the window and its root view controller are already set up.Other projects don't have a
MainWindow.xib
. The target's “Main Interface” is empty. Instead, theUIApplicationMain
function creates an instance ofAppDelegate
, sets it as theUIApplication
's delegate, and sends it theapplication:didFinishLaunchingWithOptions:
message. The app delegate handles that message by creating aUIWindow
, creating a view controller (or several), and setting the window'srootViewController
property. The default version looks like this:Some projects have a
MainStoryboard.storyboard
. I'm not going to describe this in detail because it doesn't seem relevant to your problem.The problem you're describing makes it sound like you're using half of the first template, and half of the second template. That won't work. You need to decide which approach you're taking, and go all-in.