Trying to run a simple app with UITextField - Simulator is crashing - iphone

I have two UITextFields in the App as IBOutlets and I have made a connection from File's Owner to these ... When I run Build and Go, the iphone simulator crashes ... and in the console (after debugging) ... its showing me following ...
2009-08-22 18:11:40.869 Control_Fun[1138:20b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "Control_FunViewController" nib but the view outlet was not set.'
However, I am not having any outlet (IBOutlet) explicitly defined as view ... is this something hidden? When I Control Click File's Owner and drag it to the UITextFields, it giving me three options in the gray pop-up menu to connect to
1. nameField (declared as IBOutlet property in the header file)
2. numberField (declared as IBOutlet property in the header file)
3. view (where is this coming from?)
Thanks

Figured it out - It was a View-Based Application template from where I started so there was a parent View which was defined as a outlet (by default) and it still needed to be set (with File's Owner - in this case) ... working now.

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..

Connecting a nib to files owner problem

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)

Connecting a UILabel to an IBOutlet causes a crash

I have a UIViewController I am loading from a xib file and pushing onto the navigation controller stack.
In the header file for the View Controller, I have:
IBOutlet UILabel *myTitle;
I don't do anything with "myTitle" in the code yet; I was just setting up the connections.
When I compile and run the application, and there are no labels defined in the xib file (and thus, nothing attached to the IBOutlet), it works. The view controller animates into view just fine, showing the view I built in Interface builder.
If I add a label to the xib in the interface builder, but don't connect it to the outlet, and recompile, it still works, showing the label with the default text I entered for it.
But if I connect the IBOutlet myTitle to the label in interface builder, recompile, and run the app, it works fine until I try to push the view controller onto the navigation controller's stack, at which point I get a crash:
*** -[UILabel copyWithZone:]: unrecognized selector sent to instance 0x4558e20
If I disconnect the outlet again, it resumes working, showing the static label as before. It appears that there's something funky going on when the view gets displayed, because the crash happens when I push the view onto the navigation stack.
Am I not supposed to add an IBOutlet to a UILabel or something? Or is there something else going on? Any suggestions on where to look for trouble?
Yes, it could be caused by wrong param name, e.g. try this:
IBOutlet UILabel title;
and it'll call an exception like that:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UILabel copyWithZone:]: unrecognized selector sent to instance 0x143f520'
Did you create an accessor for your IBOutlet?
#property (assign) IBOutlet UILabel *myTitle;
And then, in your .m file
#synthesize myTitle
I had the same problem. Turns out *title is reserved and Xcode doesn't tell you this. Once I renamed it to something else it worked.
In my case I had a UILabel in a UIToolBar. What fixed it for me was to delete the toolBar and add a new one with a new UILabel. An IB bug.