Connecting a nib to files owner problem - iphone

So I am upgrading my iPhone app to be universal. I upgraded the project and than created a new nib for one of my classes. I set the custom class for that nib to my viewController and dragged the view from files owner to the nib. All worked fine. But than the second time I ran it, I got the following error:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the
"viewControlleriPad" nib but the view outlet was not set.'*** Call stack at first
throw:
So I disconnected view from the nib, than reconnected it and it worked. So basically the pattern seems to be every time I link it, it works once. This seems really weird. Thanks in advance for any help.

In the new XIB that is created I suppose you have not associated the class of the File's Owner with the class of the view controller
Also you have not set the view outlet of the File's Owner.
Hope you get it.
If you need more help than please let me know.
EDIT:
Please refer to this question:
Iphone sdk tabbar View outlet was not set
EDIT-2:
View Objects don't connect to the File's Owner

This happened to me before as well. It would be worth a try to try the following in this order:
Copy + paste your nib in xcode, rename the old one, name the new one to the old name
Rebuild the nib from scratch if it is not too much trouble
Restart your Mac
Examine the XML for the nib for any oddness
(#2 worked for me)

Related

My app crashes and does not change views when I tell it to

My app crashes and does not change views when I tell it to. I have tried many other things but I can not get it to change programmatically for the life of me. I have attached my Workspace. Any help would be great!!!
Image
This code changes the view to this
self.messagesController?.setupNavBarWithUser(user)
How do I go to this view in my storyBoard correctly.
Here is my error code
2018-12-17 07:56:00.777229-0500 Kind Point[7129:524001] ***
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: 'Could not find a storyboard
named 'MessagesController' in bundle NSBundle
</Users/Jake/Library/Developer/CoreSimulator/Devices/C748FA7B-1F41-49C3-8A72-F3A39E494146/data/Containers/Bundle/Application/C824E34D-60DB-4CEC-8FEF-9BC939AF20C8/Kind
Point.app> (loaded)'
*** First throw call stack:
If you are using buttons, I suggest disconnecting the outlet/remove the segue from the button and re-add it.
Your terminal log says that there is no storyboard named MessagesController so, try adding a new view, or swift file and name it MessagesController. Add the messagesController to the view controller and see if it works.
To add a new view controller file to a storyboard, just copy and paste the code from one view controller and paste it to a new swift file. Then, change the name in the top of the code from ViewController, to the name of the view controller you want.

Error After Duplicating Storyboard

Previously i had an existing iphone project.
Afterwards i want to create its iPad version so I duplicated the existing iPhone MainStoryboard to save my time, so I changed the line:
targetRuntime="iOS.CocoaTouch"
from the new storyboard (named MainStoryboard_iPad) to:
targetRuntime="iOS.CocoaTouch.iPad".
Finally I set Main Storyboard in iPad Development info to "MainStoryboard_iPad. But I don''t know why some how i got this error:
2012-10-11 13:28:07.852 CollViewSmpl[3170:c07] * Assertion failure in -[PSUICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2372/UICollectionView.m:2249
2012-10-11 13:28:07.878 CollViewSmpl[3170:c07] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier cellID - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
Anyone know what could cause this error and give me some workarounds? FYI, I use open source PSUICollectionView library inside the project in place of UICollectionView
That inconsistence error is because the storyboard source code were not being saved properly. Finally i created a new storyboard document targeted for iPad. I copied all source code of the preexisting iPhone storyboard and pasted them into the new one. I didn't forget to save the document (this is important) and gotcha, all the stuffs are now working very well.

XCode is attempting to load a NIB file that I deleted from the project

I started working on a view with a NIB file and decided to delete it from my project to build it programatically. There are no mentions of the supposed call to the NIB file in any of my code and the .XIB doesn't exist anywhere in any of the application directories. Here's the exact error being thrown at me from the debug console.
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:
'-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "GESplitMainViewController"
nib but the view outlet was not set.'
I cannot comprehend why the xcode is still attempting to load the NIB.
Firstly, the default implementation of initWithNibName:bundle searches the bundle for a nib that shares the same name as the view controller's class if you pass nil as the first parameter, which is why your app is trying to load one.
The fact that it is finding one is probably because the .xib you used to have in your project is still included in the bundle that the simulator is running. Xcode has a habit of leaving deleted resources in the simulator bundle even if you delete them from your project.
If you delete the app from the simulator, clean your Xcode project and run again, it should stop trying to load the nib.
Although this is the reason your app is loading from a nib, it is not the reason it is crashing. The crash is because the old .xib you were using didn't have a view connected to the view controller's view outlet.
If you have not used nib name anywhere in application, first delete application, clean your build and test it, hope this solves your issue..

'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the GameView nib but the view outlet was not set

This is not the same situation as the multitude of other similar questions here.
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the GameView nib but the view outlet was not set.'
You might be thinking "do as it says, connect the File's Owner to the View in IB!". But the thing is, I don't even HAVE a GameView.xib in my project or even in the project directory.
I do have a "GameViewController.m" and matching "GameViewController.xib" in my project. Using that GameViewController is what brings up this error, but I don't understand where it gets the idea to try and load "GameView.xib". Shouldn't it use "GameViewController.xib" instead?
If I grep my project directory, I do see it referenced from "UserInterfaceState.xcuserstate".
<string>file://localhost/Users/bemmu/Dropbox/b2/iphone/ValleyStory/ValleyStory/GameView.xib</string>
This mentioned file does not exist. I might have had a file with that name before and renamed/deleted it, but it's not being referenced to from anywhere that I can see in IB.
Did I manage to confuse xcode?
My solution was a little different.
Click on the xib in interface builder
Select File's Owner on the left
Open the File's Owner's connections inspector
If the view property isn't yet wired, control-drag it to the view icon (under the file's owner and first responder icons).
Check any nib files you're using (like MainWindow.xib). If you are loading GameViewController from a nib, check the file it's loading from (under the info tab in the inspector). Make sure it's set to "GameViewController" and not "GameView".
I had this issue as well, but had to solve it a different way. Basically, I have a view controller name MainViewController, which has a xib named MainViewController.xib. This nib has it's view property set to the File Owner which was MainViewController.
I also made a MainView.xib that contained a view that was going to be programmatically added to the view defined in MainViewController.xib and it's view. It basically encapsulated an internal view that would be in the MainViewController.xib's view, and also had it's File Owner set to MainViewController.
So basically, I wanted MainViewController.xib to load as the nib for the MainViewController object, and inside MainViewController, at some later point, I would add the internal view specified by MainView.xib.
A couple issues arose:
1.) I found in the Apple docs that when loading a view controller via storyboard or nib:
"If the view controller class name ends with the word “Controller”, as
in MyViewController, it looks for a nib file whose name matches the
class name without the word “Controller”, as in MyView.nib.
It looks for a nib file whose name matches the name of the view
controller class. For example, if the class name is MyViewController,
it looks for a MyViewController.nib file."
Therefore, you cannot have a nib called MainView.xib if you also have a nib called MainViewController and want MainViewController.xib to be the primary nib for MainViewController.
2.) Even if you delete MainView.xib or rename it to something else (MainInternalView.xib in this case), you MUST delete / clean your iOS simulator as the old nib file (MainView.xib) will still remain in the application. It doesn't overwrite the whole application package when you rebuild / rerun your application.
If you don't want to reset your content settings (perhaps you have some data you want to preserve), then right-click on your application in your iOS Simulator folder, Show Package Contents, find MainView.nib, and delete it. Xcode will NOT do this automatically for you when you rebuild, so we need to manually remove the old nib.
Overall, don't make nibs named MainViewController and MainView, i.e. nibs with the same prefix. Call MainView.xib something else, like MainInternalView.xib.
I recently solved this issue. Make sure you back up your project before following the steps given here (just in case). These steps solved my issue
Quit Xcode
Navigate to UserInterfaceState.xcuserstate located at .xcodeproj/project.xcworkspace/xcuserdata/<username>.xcuserdata and delete the file.
Reopen Xcode. Xcode will create a new UserInterfaceState.xcuserstate which will be clean.
In my case this error was produced by dumb mistake - I delete _view view
In my case, I was not using a xib at all. I needed remove the .m file from Build Phases > Compile Sources and added it back.
Given you referenced it previously it sounds like xcode hasn't ackowledged it no longer exists. From the Product menu select "Clean" and then "Build" hopefully this will get past the old reference for you.
Face the same Problem, had to change the view's name in code:
MyViewController *controller = [[MyViewController alloc] initWithNibName:#"WrongViewName" bundle:nil];
To
MyViewController *controller = [[MyViewController alloc] initWithNibName:#"RightViewName" bundle:nil];
I had multiple views, and by accident (I don't know how this happenned) but my background view didn't have a file owner, so for anyone else who has this problem in the future, make sure all your views have a file owner.
I was gettint the same error then check the classname from interface builder and see that I typed the view controller class name at the custom class attribute.
UIViewController searches for a nib with the same name as the controller when passed nil to initWithNibNamed:bundle: Check that the file name that you pass to the initializer is correct and exists!
For example:(e.g. [[CCVisitorsController alloc] initWithNibName:nil bundle:nil] then UIViewController tries to load nib with name CCVisitorsController as default.
If that file does not exist then the error you mentioned is thrown.
I had this problem because I was doing something bad in
(id) initWithCoder:(NSCoder *) coder
which the NIB loads.

SIGABRT on iPhone when changing xib

I've just finished off an app for the iPhone which, until today, ran fine on the iPhone simulator and actual devices.
I tried changing the xib which is loaded in the applicationDidFinishLaunching method in my application delegate class - all I did was change the string in initWithNibName.
When I launch the app on the simulator, the Default.png image is shown, then the app crashes with an uncaught exception. When running on a device, the Default.png image is shown for about 10 seconds, the UI is never loaded and I get 'GDB: Program received signal: "SIGABRT".' on the Xcode status bar. Debugging shows that applicationDidFinishLaunching is never actually reached before the app crashes.
Setting the starting xib back to the original solves the issue, but now I've made a change and saved it in the Interface Builder and the app shows the same issues as above - I've made no code changes at all.
Is this a memory issue, or a known issue of a common mistake?
NOTE: I've made no code changes whatsoever, and the only changes I've made to the xib are cosmetic, the IBOutlets are all intact.
You probably changed an IBOutlet's name in code without changing it in the xib.
Sorry guys, my fault - it appears I deleted the MainWindow.xib file, so the delegate wasn't called on startup after I made changes. I've recreated it and linked it to the app delegate and UIApplication so now everything works.
You probably had IBOutlets connected from a xib back into your code, and those connections are broken.
You'll have to give us a little more detail on how the nibname string was changed. Did you rename your xib file?
I renamed some classes and Xibs and got SIGABRT into main.m
the Class name in Identity Inspector may be pointing to non existant class name
its because in the initWithNibName you are not giving the correct xib name so it will crash