Storyboard doesn't contain a controller with identifier 'MainWindow' - objective-c

I am trying to instantiate an NSWindowController from a storyboard in my OS X app:
NSWindowController *mainWindowController = [[NSStoryboard storyboardWithName:#"Main" bundle:nil] instantiateControllerWithIdentifier:#"MainWindow"];
But this is what I'm getting:
Storyboard (<NSStoryboard: 0x618000008500>) doesn't contain a controller with identifier 'MainWindow'.
But in the storyboard:
It is set. No, there are no other storyboards. Yes, I've tried cleaning the project and the build folder, but nothing changes.
Why would I get this error?
UPDATE: I am building my app, coming back to the storyboard, and I see that Storyboard ID is unset:
How can Storyboard ID get unset by itself?

It was definitely a bug with Xcode. Restarting Xcode solved the problem.

Related

ios8 unwind segue not working with UINavigationBarController and UITabBarController (Fixed in iOS 8.1)

I just started testing my iOS7 app on iOS8 with Xcode 6 (beta 6). I am aware that iOS 8 has deprecated the "push" and "modal" segue but I was happy to find that all my segue's worked... except one.
I built a demo app to show that unwinding from a modal segue seems to be broken if your app uses a UITabBarController with UINavigationController. (I saw another unwind segue post, but it was using swift, where as my demo app is using obj-c).
Here is what I am seeing more specifically:
[UITabBarContoller] -> [UINavigationController] -> [SomeViewController] -(Modal Segue)-> [This ViewController Cannot Unwind]
Interestingly, you CAN unwind if you do another modal segue:
[UITabBarContoller] -> [UINavigationController] -> [SomeViewController] -(Modal Segue1)-> [This ViewController Cannot Unwind] -(Modal Segue2)-> [This ViewController CAN unwind]
I also found I can unwind if I remove either the UITabBarController or the UINavigationController, but I do not plan on changing my entire app UI architecture :)
From what I can see, the root view controller never receives a call to canPerformUnwindSegueAction:fromViewController:withSender: which it does in iOS7.
My Question: Is there a different way I should try to get my unwind segue to work?
Thanks for reading.
Demo code is here: https://github.com/nmsasaki/UnwindDemo
UPDATE
This issue seems to have been fixed by iOS8.1. (The iOS 8.0 work around of creating a custom subclass of UINavigationController continues to work.)
Override viewControllerForUnwindSegueAction in UITabBarController by create a custom UITabBarController and use the custom one.

iOS7 Storyboards: App crashes after calling addSubview

I am working with the iOS book "Hello iOS Development". I coded along the book and just finished chapter 4. After implementing everything like in the book my app crashes.
I guess it's because I used Storyboards (Xcode 5 and iOS7), the author uses XIB files. Here's an image of the error:
What does the error mean? What's wrong with it? Does the addSubview refer to the XIB files I don't use due to Storyboards?
I'd really appreciate your help with this!
You cannot simply alloc] init a view controller whose view is defined in a storyboard or XIB file, as you have. Doing so will not yield what you expect.
If you are using a storyboard, you should give your card view controller an identifier in the storyboard, and then [self.storyboard instantiateViewControllerWithIdentifier:#"_CardViewControllerIdentifier"];
This will create a view controller with a view as set in the storyboard.
If you do not use a storyboard, but a xib file, you should use initWithNibName:bundle: to instantiate your view controller.

Missing proxy for identifier UIStoryboardPlaceholder [duplicate]

This question already has answers here:
Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?
(79 answers)
Closed 7 years ago.
Hi I seem to have stumbled upon weird thing while developing a storyboard app.
My app is halted right after splash screen and in console I get error message:
Missing proxy for identifier UIStoryboardPlaceholder
Now, if I try to let the app continue running, I get new messages into console, which I believe are related to the fact, that there is something wrong with the first error message
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason:
'[<IntroViewController 0x6e35f40> setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key sceneViewController.
What is strange I get this error only when working with iOs 5.1 Simulator. It works fine on iOs 6 simulator and also on devices with both iOs 6 and iOs 5.1
I tried to find answer, but google says it could not find any results for the word UIStoryboardPlaceholder, let alone the whole error message. I made sure, I don't have the word 'UIStoryboardPlaceholder' anywhere within my xcode project(not even inside nib files) and also there's nowhere mentioned 'sceneViewController'. Any idea what might be wrong?
EDIT: I tried to reset simulator and cleaning project, but to no avail
We had the same problem: a view controller in a storyboard file with its interface defined in a separate XIB file. (Using Xcode 6.3.1, iOS 8.3 and Swift 1.2.)
We are using Swift so we had added the #objc() declaration to the class declaration:
#objc(TestViewController) class TestViewController: UIViewController
We could instantiate the view controller just fine from another view controller using self.storyboard?.instantiateViewControllerWithIdentifier( "TestViewController" ) but when presenting the view controller (using self.presentViewController( viewController, animated: true, completion: nil )) the app crashed with the same "missing proxy" and "not key value coding-compliant for the key sceneViewController" error.
Our solution which we found after much frustrated trial-and-error-like debugging was simply make sure the view controller's Storyboard ID in the storyboard file is not the same as the class name.
When we renamed the Storyboard ID from "TestViewController" to "testViewController" (only difference being the lower-case first letter), everything worked…
Strange? You betcha, but everything seems to be working now.
I had the same problem. Try cleaning the project and restoring the simulator.
I was getting the same error with an app that I was converting from .xib files to storyboards. My app contained a UITabBarController, and tapping on certain tabs would trigger the error.
In my case, the problem was that I had copied view controllers into the storyboard that used the "NIB name" property to load the view controller's view from an external .xib file. Storyboard view controllers do not support loading views from .xib files, so my storyboard contained a view controller that had no view.
I opened the external .xib file, copied the view, pasted it into the corresponding view controller in my storyboard, and made sure that the pasted view was subordinate (indented under) the view controller in the storyboard scene. Then I re-connected the view to the outlets in the view controller.
When I re-ran the application, the error was gone.
Add me to the list. I get this error after "refactoring - rename" on a class. The class I am renaming is a custom ViewController with its own .xib. I use Storyboard which launches a viewController containing a "Container View", which has my custom ViewController embedded in it upon launch.
The only way out of this so far is to NOT use my refactored .xib (disconnect it from the container view).
My semi-solution:
I have restored my app from a prior working snapshot and created a new custom ViewController and .xib from scratch instead of refactoring. Connected it to Storyboard and I got the error message again. Cleaned the build and deleted the app from the simulator and re-ran, and then it magically ran without error. For this reason I believe there is a bug in Xcode with Refactor-Rename, which corrupts some storyboard file behind-the-scenes. Once I confirmed that the new .xib was attaching to storyboard without error, I copied/pasted the class code into the new custom viewController class, and went through the process of reconnecting the class objects to the .xib, as you'd expect. Ran it and everything still worked.
FYI - here are some of the FAILED steps I took in my attempt to recover from the error (before giving up and restoring snapshot).
1. Cleaning Build.
2. Deleting App in iOS simulator.
3. Deleting all views in the custom ViewController .xib.
4. Naming the custom ViewController something else.
5. In Storyboard, adding a blank view to the ViewController representing my custom Viewcontroller class. This worked and allowed my app to run, however my custom class was neither able to load its own views in place of this default blank view, nor were it's own views visible upon making the default blank view transparent. Debugging showed my custom class .xib views being nil when assigned to self.view.
I am presently avoiding Xcode's Refactor-Rename for files having a .xib.
I had the same errors, finally solved it.
My problem was that I had :
[[storyboard instantiateViewControllerWithIdentifier:#"TripDetail"] methodThatDoesNotExist:#"param"]

Im getting an error in my root view controller

I know it's a very common error .. I'm using storyboard and I'm getting this error, here's my AppDelegate.m screenshot
keep in mind that I'm beginner and the reason of that maybe so stupid :)
Thanks in advance!
(it's not a bug but I'm just getting a black screen on the simulator)
Use:
window.rootViewController = viewController;
instead of:
[window addSubview:viewController.view];
If I remember correctly, you don't create a UIWindow yourself when you use storyboard. When using storyboard, the main UIWindow is created for you. Since you created your own UIWindow, it's just overlapping and covering up the existing UIWindow. Set the rootViewController in .storyboard by pointing that arrow to it.
By the way, did you create a single view application or an empty application?

Extracting nibs/xibs from storyboards (iOS)

I have created a simple project with a storyboard, and now realize that they don't support iOS 4.x and that I would like users with these devices to be able to download my app. The app is just a flipside view controller, and is fairly simple but if there's a way to just extract the XIBs from the storyboard I'd much prefer to do that than recreate it.
tl;dr: getting .xibs out of a .storyboard?
Xib files cannot be extracted from the storyboard but you can instantiate UIViewControllers out of the storyboard by instantiating your storyboard into a UIStoryboard Object and getting the UIViewController via its identifier, here's how I do it:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:
#"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
UIViewController *myController = [storyboard instantiateViewControllerWithIdentifier:#"myId"];
hope this helps.
I found that the simplest method was to copy and paste the items out of the storyboard, one view at a time, and recreate the view controllers for each one.
However, for anybody who does this, note that you have to make a xib for MainWindow in addition to all of your other XIBs, and hook it up accordingly, including setting up the window and app delegate. Storyboards handle all of this for you, so when you try to avoid them, you have a lot of manual setting up that creating non-storyboard projects from the get-go handles for you. Don't do what I did, and try to make your root controller your main view controller, because it will go nuts saying things about how UIApplication isn't key-value compliant for individual properties of your XIB.
As a few others have suggested, your best bet is to clone the views from storyboard into an XIB.
It's not possible to get xib files. Your storyboard is compiled to nib files and packaged into a storyboardc file within your app bundle.
To locate the nib files select your built executable in Finder and right-click 'Show package contents'. Navigate to the en.lproj directory and find the storyboard.storyboardc file. Right-click 'Show package contents' again on the storyboard file and you will find your nibs. They will not be much use to you though because they are compiled binary nibs.
You may not be able to extract the .xibs from the storyboard, but try this. Have your .xib based project open and create the empty .xib files for your views and also have the storyboard project open at the same time. Select all the UI elements in your storyboards scene and simply drag and drop them over to the .xib based project. I have done this the other way around (moving from .xib to storyboard) with no problems.