"loaded the "XXX" nib but the view outlet was not set." - again - ios

Firstly I have inspected all of the other questions on this topic: the answers provided seem to be:
make sure you set the file's owner to your custom view controller class (which I have done)
make sure you have a referencing outlet from the view to the file's owner (which I have)
My code is compiled to a static library, and I export the .a file and xib file.
My example app that uses it includes the xib in its bundle ("copy bundle resources" in build phase)
In my library code I have a function in a separate UIViewContoller subclass to create the view controller from the nib:
- (void) presentCustomController
{
self.vCtrl = [[CustomController alloc] initWithNibName:#"CustomController" bundle:nil];
...
}
When I run the example app, I inspect the _view member of self.vCtrl, and it is 0x0000, and of course this is what causes the exception in the posting title.
My understanding was that the view to which that member points was 'auto generated' from the xib file, and it's children were the controls that I have put in it (buttons etc).
What part of my understanding has fallen down? Is the problem related to the fact that it is in a static library?
Thanks for any help.

If you are 100% that you connected your View to the File's Owner then I suggest you do the following:
Clean the project (cmd+shift+K) or Clean Build Folder if you prefer (cmd+shift+alt+K)
Quit Xcode
Restart Xcode
That should fix it hopefully.

Do you have multiple targets?
make sure you set the file's owner to your custom view controller class (which I have done)
I have come across a similar issue where I thought that I was setting the file's owner's custom class, however, IB was not actually setting it. Open the XIB as its raw xml and search for the custom class name.
For me it was because the .m of the view controller was not included for my specific target. To fix this check all the boxes in the target membership pane.

Related

Unknown class in interface builder

I know that there are a lot of questions on this subject but I've tried most of them to try and figure it out with no success.
the problem:
at first I couldn't add my class from the assistant editor cause the custom class didn't pick it up.
I made sure the calls inherits from uiviewcontroller
I made sure the class is added to the target
I tried to remove the class file and re-add it back
finally I've added the class through the storyboard xml and it appeared in the custom class
Now I'm trying to connect my buttons, views etc to its outlets. It seems like they are connected but when running the app and opening that view controller the app crashes and the debugger prints:
"Unknown class xxx in Interface Builder file."
and than
"this class is not key value coding-compliant for the key btnMenu."
I've checked:
That connection inspector is properly set (no error in the outlets there)
Tried to delete derived data
Clean project
Re-install the app
I even tried restarting my mac and of course no success.
can anyone shad some light here?
thanks.
I just had this happen with a UIViewController subclass (with Xcode 9 beta 2 & Swift 4) and the solution was to tick 'Inherit from Target' where I set the Custom Class in IB.
If your view happens to be in a .bundle file (such as for a framework/static library) that gets copied to a different target, you'll want to set an explicit module target for each xib/storyboard class rather than having it inherit from the target that's hosting it.
For me the problem was that the class was not part of the Target Membership. Just add the class to the target, and you should see it back on the interface builder. This Helped in my case.
After I checked the tick mark called "Inherit Module From Target" in Custom Class in View Controller Section, it works fine. Can Follow the image.
To find this >
Select your view controller yellow button > then click "Show Identity Inspector" > then checked the tick mark called "Inherit Module From Target"
What #Anthony Scott mentioned is true until you have Framework_A dependent on Framework_B and class is from Framework_B :) Then you need to deselect checkbox and provide Module which contains given class. Thanks for the question btw. I am using Commons framework for other frameworks and it helped me to realize this ;)
For those who develop custom Cocoa Touch Frameworks this can be helpful.
If you are trying to assign a class to a ViewController, please make sure the class you created is inheriting a UIViewController. The only reason that xCode won't recognize your class is where it is a different type of instance, let's say, may be a UITableViewController type.
Please check the inheritence of your class first.
I had this problem with a custom UIView I was testing, where the UIView was in a framework. I had created a simple app, created a UIView in the Storyboard's default ViewController and set its class to MyCustomView. I always got the "Unknown class in interface builder" error when the app launched. I was importing my framework, and I checked in the built product that the framework was there.
The problem was that my test app code never actually used the framework. Even though the Storyboard referenced it, I guess it never got loaded. When I added a [MyCustomView load]; into the test app code, it all worked.
For those who encounter this problem but with a system class like PKCanvasView or ARView, in a storyboard.
After you've set view's Custom Class to any of those system classes, make sure the Module is set to None. Next go to target's Link Binary with Libraries in Build Phases and manually link the framework which contains that class. One last step is to do a clean and remove derived data (it's critical otherwise the problem won't float away).
ok so i dont know how and why, but, i did (AGAIN) what i already tried before which is:
deleting the class
creating the same class with new name
removed the scene and recreated it in the storyboard
connected it all (in the same usual way!!!)
now it seems that Xcode knows my class....
i still don't know what was the problem but i guess it has something to do with the linker.
I ran into this error because I accidentally saved my class file to the Base.lproj folder when I created it.
I fixed the error by right-clicking the file in the Project Navigator and deleting the reference to it. I then moved the file through Finder to the correct folder. Then I right-clicked the main group in the Project Navigator and clicked Add Files to "GroupName"... and selected the class and clicked the Add button.
After that the error went away.
Check the name of your class. Make sure that it corresponds to the class to which you have assigned your ViewController in the property inspector.
You need to instantiate the view controller with the custom class. Without that you might have the error.
self.storyboard!.instantiateViewController(withIdentifier: "namePage") as! EmailAndPassword
none of this helped. My problem was I created custom storyboards and added custom classes. But I forgot to take of the initial view controller arrow from auto-generated main storyboard and changed the initial storyboard to my custom storyboard which fixed it for me.
I found the problem for me was that the UIViewController that I was pointing to did not have a ViewController.swift file attached to its "Custom Class" parameter!

Changing a .swift to connect to a Table View Controller not a View Controller

I have an IOS app that displays items. I have a working "MYItemCell.xib" and a "MYItemCell.swift". I have just added a new type of item that will be displayed somewhat differently. It is named: MYItemTwoCell.xib/swift
Right now I am trying to keep most of it the same, so I just copied over both the .xib and the swift file and renamed things. But I cannot connect my new .xib to my new .swift. It remains connected to the old .swift
I was having this problem: Xib file: Can't drag a View from a xib file to a swift file . So I tried to make the "container" in the .xib file of the class in my .swift file.
But, when I write in my new class name "MYItemTwoCell" it always reverts back the "MYItemCell"
When I click the down arrow on the selector it only suggests "UITableViewCell" and "MYItemTwoCell" is not listed.
EDIT 1
I believe the issue that the MYItemCellTwo cannot be a UICollectionViewCell. It will connect to a blank UIViewController that I add. In other words: I cannot make a UICollectionViewCell a MYItemTwoCell class but I can make a UIViewController a MYItemTwoCell class.
Does anyone know how to make my MYItemTwoCell a UICollectionViewCell class not a UIViewController class?
You need to use the Identifier inspector from the MYItemTwoCell.xib file and reference your MYItemTwoCell.swift file.
Don't worry if you not see it, write class name.

Can I connect a custom xib to a class in a framework?

I've got a class and xib that are fairly generic. The xib has a base UI that I've included in a framework. Is it possible for me to add the framework to a project, and create a custom xib to customize my framework xib based on the new project UI needs?
|------------------------|
| MyFrameworkClass | MyCustomXib
| MyFrameworkXib |
|------------------------|
In MyCustomXib i've set the custom class of the files owner to MyFrameworkClass. I notice that I can wire up all my IBOutlets by right clicking on file's owner and dragging to the subviews to make the connections, however I cannot click on the view and drag to file's owner. Also When I go into split view mode I'm not seeing MyFrameworkClass as the code side of the split view?
Right now i'm trying to initialize it with:
MyFrameworkClass *mfc = [MyFrameworkClass alloc] initWithNibName:#"MyCustomXib" bundle:nil];
I'm confused because I'm seeing labels that are created dynamically in MyFramework class showing up in the custom UI, also newly modified button images are replacing old ones, however the buttons are not responding to touches, and the xib resizing is not working correctly.
Edit:
I just went through and compared the xib in the framework and my custom one and found that I could connect all my Outlets to the proper UI elements, however I could not connect any received actions using interface builder. By that I mean when I ctrl+click on a button and drag the connector up to File's Owner, I do not get the glow around File's Owner or a prompt to connect to any methods.
Yes. As long as the class is loaded into the runtime when the XIB file is read, it will work perfectly fine.
It will work. :-) Post additional details of what you mean by "framework" if it doesn't.

Storyboard uiviewcontroller, 'custom class' not showing in drop down

I have a UIViewController I created in my apps storyboard, as well as a custom UIViewController subclass which I added to the project (and is correctly in the compile phase for my target). However when I go to set the 'Custom Class' property on the view-controller in Storyboard my custom class does not show up on the list.
Checked that the class is part of my app's target, not tests'
Double checked that it is correctly a subclass of UIViewController
Compiled program just to make sure xcode was working with latest information
Restarted xcode
What would cause my class to not show up in the 'Custom Class' drop down?
Two ways I found that solve the problem but they are work arounds:-
Just type the view controllers name in the text field, or
close the project and then reopen it and in the project initialization it places the file on the list.
If you still have your problem or for those who could have the same problem:
Make sure to select on your storyboard your "ViewController" instead of your "View" (which is automatically selected when you click on the view in the storyboard). The difference between those two is that when the view controller is selected, a blue rectangle pop up around your app. To be sure to select the view controller, open the document outline and select it directly in your storyboard hierarchy.
I would try the following:
Check that the file implementing the class is part of the build phases (check under target > build phases)
Add the .m file to build phases (if it isn't already).
Restart Xcode.
You can fix this by editing the XML of your Storyboard.
Right-click your My.storyboard entry in the Project Navigator panel and select the Open As->SourceCode menu choice. Find your view controller entry in the XML, and add the attribute customClass="MyController".
Save the storyboard.
Right-click your My.storyboard entry in the Project Navigator panel again, and select the Open As->Interface Builder - Storyboard menu choice.
The custom class entry will now contain your MyController class name.
Make sure your class inherits from UIViewController.
#interface ClassName : UIViewController
In Xcode 8, a few of my classes had the wrong path (case sensitive) specified for their file locations.
MyProject/mysubdirectory/MyViewController.xib (.m, .h)
vs:
MyProject/MySubdirectory/MyViewController.xib (.m, .h)
Really not sure how it ended up in that state, but my project exhibited the exact same behavior as above (no outlets/actions displaying in IB), and fixing that path fixed the problem.
I fixed this two different ways. One way was by I opened the .pbxproj file and fixing the case sensitive issue manually. The other way that worked was by tapping the folder icon under the Identity and Type section of the File Inspector tab of the file, and re-selecting the file there.
Click on a different view controller in the storyboard, then click on it's custom class pulldown to confirm the new class is listed, but don't select it. Click back on the new view controller you made and you should see it now listed in its custom class pulldown menu. odd, eh? just forces a refresh I think.
I had been having the same issues as described in this problem. However, none of the suggested answers fixed it for me. My project compiled OK without warnings or errors, but, in the .h file there were no 'outlet' indicators to indicate that my outlets had been linked to storyboard elements.
Additionally, attempts to create new outlets in my code, by right-click and dragging into my header file, were not recognising my header source as a potential target for this operation. And furthermore, my Class did not make an appearance in the Custom-Class dropdown for the ViewController's property inspector panel.
And yet, the project compiled OK.
Closer examination showed that I had defined my own class in the following manner...
#interface KJBMainDataViewTrackConMk2<UIScrollViewDelegate> : UIViewController
which apparently compiles nicely.
But, if this is changed to the following, (moving the protocols to the end)...
#interface KJBMainDataViewTrackConMk2 : UIViewController<UIScrollViewDelegate>
Then everything springs to life. All outlets are suddenly indicated as being 'connected' with a storyboard element. And right-click dragging starts to work again, and my custom class appears in the custom-class drop-down in the property inspector panel for the storyboard ViewController!
Other answers here probably represent the most likely causes of this condition, but, I felt it worth mentioning at least this one other potential cause.
I had the same problem, but none of the other solutions worked for me. The issue for me was that I had a Mac and iOS target, both with their own versions of the same view controller. For example, I had a .h/.m pair of files named FooViewController for Mac and another .h/.m pair of files named FooViewController for iOS. Each pair was properly included with their respective targets, but for some reason Xcode does not like it and my view controller would not show up in the Custom Class dropdown in the view controller in the storyboard. I ended up renaming my class in the iOS view controller and it immediately showed up in the dropdown.
In my case, I drag a new TableViewController object to the storyboard, but I add a new file which's subclass is "UIViewController".... Then, I add a file which's subclass is "UITableViewController", problem solved!!
For those of you who are still having this problem after trying all the way around is probably because you clicked the View instead of ViewController.
You have to choose the file when ViewController is clicked.
This solved my problem.
I happened to come across this problem, and had no luck after trying the previous suggestions. Finally I found the reason is the header file's type is set to C++ header. After changing it to C header (like all the other header files), the class appears in the drop list. Don't know why though... Possibly helpful for others so I post it here.
Storyboard is looking for the custom class but physically its no there and its not displaying the custom class name in the list and also not displaying the outlets . Following solution perfectly worked for me.
Just copy your code some where else.(Lets say on desktop)
Open your existing code.
Delete the custom class file.(Move to trash)
Now add files from copied project folder (From desktop)
Don't forget to check "Copy if needed" check box
Open the story board and bingo you will get your custom class files in dropdown
be sure initially not adding the CustomViewController to any group or folder. place it in the root of your app.
none of the above(or below :) helped me. though I found that
after adding new viewcontroller to storyboard (just by dragging it in)
and adding my class by File\New\File\Objective-C Class, give it a name, no XIB, Next, Create
if I select my viewcontroller in storyboard and try to assign my class to it - my class is not there
BUT
if I click on a view that is in the viewcontroller itself then click on a class dropdown menu in Custom Class
AND THEN
select viewcontroller (click on a bar below the viewcontroller) and now again click on a class dropdown in Custom Class my newly added class magically shows up.
weird, must be a bug with refreshing. Xcode Version 5.1 (5B130a)
Make sure you select View Controller to which you want to attach your class. The easy way is open Document Outline and choose your view controller (When you tap on it form the Storyboard sometimes it simply doesn't choose the object you meant).
for my case, somehow bundle resources got deleted, so I added back and worked!
Build Phases -> Add Build Phase -> Copy Bundle Resources
find your file
Then drag and drop your file there
Then make sure your target membership is checked.
In my case, I selected the wrong UI.. so I deleted the class file and created a new one and selected the correct parent class
I had to restart XCode 7.3 (7D175)
What worked for me was, click on the file in the Project Navigator, then, in the File Inspector under "Identity and Type" beneath the "Location" dropdown box, click on the little folder icon and then select the file in the popup window.
Try to clean your project, and also restart your Mac. One peculiar thing that I did was change all the Custom Classes names and build the project again. It worked!
For macOS projects, creating a new class generated a class inheriting from NSObject instead on NSViewController.
Change from
import Cocoa
class AppsViewController: NSObject {
}
to
import Cocoa
class AppsViewController: NSViewController {
}
I was fairly frustrated with this issue as none of the answers above had solved my problem.
In my case: I was in the middle of working on swift view controller file and was making active changes (such as creating a custom collection cell class). I had not finished the code block and left it open like so :
class tableViewCell: UITableViewCell {
}
class collectionCell:
class viewController: UIViewController {
override func viewDidLoad(){
super.viewDidload()
}
}
Note the incomplete code block 'collectionCell2'
This was enough for xcode to not recognize my viewController file as such.
Once I completed this block the file reappeared in my xcode as an option.
Very silly and simple.
Make sure the view controller is matching with the same Type in the storyboard .
In my case swift file name was different then swift class name i.e
file name was ViewControllerTest.swift
and class name was ViewController.swift
after changing both to common name solved my problem
Restart Xcode after above changes
Make sure the class name of the ViewController is the name that you want. i.e.
class MyCustomNameViewController: UIViewController {
.
.
}
Changing just the filename is not enough.

Loaded nib but the 'view' outlet was not set

I added a new nib file to my project, and tried to load it.
However, when I click on the toolbar icon that is supposed to take me to the view that I created, I get an NSInternalInconsistencyException with the message:
Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: '-[UIViewController
_loadViewFromNibNamed:bundle:] loaded the "..." nib but the view outlet was not set.'
So I opened up my nib file, and I see for the view that there are no referencing outlets set. However, I try to click and drag the circle for "new referencing outlet" to File's Owner, but it won't let me...what do I need to do to get my view to display?
Here's what worked for me:
Open the XIB file causing problems
Click on file's owner icon on the left bar (top one, looks like a yellow outlined box)
If you don't see the right-hand sidebar, click on the third icon above "view" in your toolbar. This will show the right-hand sidebar
In the right-hand sidebar, click on the fourth tab--the one that looks a bit like a newspaper
Under "Custom Class" at the top, make sure Class is the name of the ViewController that should correspond to this view. If not, enter it
In the right-hand sidebar, click on the last tab--the one that looks like a circle with an arrow in it
You should see "outlets" with "view" under it. Drag the circle next to it over to the "view" icon on the left bar (bottom one, looks like a white square with a thick gray outline
Save the xib and re-run
This is Josh Justice proposal, but in a graphical way (pictures are mine):
Select File owner
On right hand side panel select custom class.
Enter the custom class name
On right hand side panel select oultets
Drag view outlet to view component
Finally the View Controller is instantiated with the rolling code:
PTFilterUserVC *aFilterUserVC = [[PTFilterUserVC alloc] initWithNibName:#"FilterVC" bundle:nil];
//OPTIONAL.This is how 'I' am interested in present the view controller.
[self.navigationController pushViewController:aFilterUserVC animated:YES];
I can generally fix it by remaking the connection between File's Owner and the view. Control-drag from the File's owner to your View (in IB) and select view from the pop-up menu.
The View Identity - Class Identity was not set. After setting it to the appropriate class, the issue was resolved.
Are you sure you have a UIView (or subclass) assigned to the "view" property of yourViewController?
Right click on "File Owner" in the left pane of the xib for yourViewController and verify that the "view" outlet is set.
If not, set it to a view!
this will definetly fix the Issue
For me all the things stated here https://stackoverflow.com/a/6395750/939501 were true but still it was throwing error, reason was I created a View class with name ABCView and then deleted it later I added a view controller as ABCViewController so somehow it was referring to old ABCView in new view controller, I had to delete the ABCViewController and add a new one with different name that solved my issue.
Thanks
I had the same issue with XCode 4.6.3. I had started out with a couple files named MySettingsView.h and .m but deleted them in favor of MySettingsViewController.h, but despite trying most of the hints mentioned here, it still kept erroring with,
2013-07-05 11:48:17.205 MyApp[39024:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:
'-[UIViewController _loadViewFromNibNamed:bundle:] loaded the
"MySettingsView" nib but the view outlet was not set.'
It was evidently still "confused", trying to load MySettingsView.xib instead of MySettingsView Controller.xib. Maybe its "do what I mean" logic is too fancy.
So I worked around the problem by hardcoding the NIB/XIB name in MySettingsViewController.m:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:#"MySettingsViewController" bundle:nibBundleOrNil];
}
I ran into this problem in a slightly different way from the other answers here.
If I simply created a new xib file, added a UIViewController to it in Interface Builder, and set that UIViewController's custom class to my view controller, that resulted in the "view outlet was not set" crash. The other solutions here say to control-drag the view outlet to the View, but for me the view outlet was greyed out and I couldn't control-drag it.
I figured out that my mistake was in adding a UIViewController in Interface Builder. Instead, I had to add a UIView, and set the Custom Class of the File's Owner to my view controller. Then I could control-drag the view outlet of the File's Owner to my new view UIView and everything worked as it should.
To anyone that is using an xib method to create a UIView and having this problem, you will notice that you won't have the "view" outlet under the connections inspector menu. But if you set the File's Owners custom class to a UIViewController and then you will see the "view" outlet, which you can just CMND connect an outlet to the CustomView.
My issue with this was caused by having a duplicate nib in the class folder that did not have the view set. xcode seemed to be choosing one nib for a build and then the other the next time I built the project. Just deleted the other one. Looks good. Doh!
Just spent more than hour trying to find out why my view property is not set in my view controller upon initiating it from nib. Remember to call "[super initWithNibName...]" inside your view controller's initWithNibName.
I just fixed this in mine. Large project, two files. One was "ReallyLargeNameView" and another was "ReallyLargeNameViewController"
Based on the 2nd answer chosen above, I decided I should clean my build. Nada, but I was still suspect of XCode (as I have two identical classes, should abstract them but eh...) So one's working, one's not. File's owner names are so far as copy and pasted, outlets rehooked up, xCode rebooted, still nothing.
So I delete the similar named class (which is a view). Soon, new error "outlet inside not hooked up" literally was "webView not key value" blah... basically saying "Visual Studio's better". Anyway... I erase the smaller named file, and bam, it works.
XCode is confused by similar-named files. And the project is large enough to need rebooting a bit, that may be part of it.
Wish I had a more technical answer than "XCode is confused", but well, xCode gets confused a lot at this point. Unconfused it the same way I'd help a little kid. It works now, :) Should benefit others if the above doesn't fix anything.
Always remember to clean your builds (by deleting off the simulator too)
The previous answers almost solved the problem for me, but the last step was missing.
Create a xib and swift file with the same name.
Set the file owner to be the UIView subclass.
Drag an outlet from the View to the UIView subclass, name it "contentView"
Add this custom initializer so when the xib loads it attaches the contentView
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
Bundle(for: self.classForCoder).loadNibNamed("SampleView", owner: self, options: nil)
addSubview(contentView)
contentView.frame = self.bounds
contentView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
}
Now any #IBOutlets you add will be attached.
Cheers,
Richard
I also had the same problem and my issue was that i added an other Localisation (English) to the ViewControllers nib so my App with the Localisation German couldĀ“t find the nib with the Localisation English!! Hope this helps anybody!
I had face the same problem while accidentally deleted xib reference and added it again.I just fixed by making connection between Files owner and the view.Also make sure that your FilesOwner's custom class is your expected viewController.
For me, the problem was caused by calling initWithNibName:bundle:. I am using table view cells from a nib file to define entry forms that sit on tableViews. As I don't have a view, doesn't make sense to hook to one. Instead, if I call the initWithStyle: method instead, and from within there, I load the nib file, then things work as expected.
I had the same problem, but a slightly different solution was called for. The problem in this case was the class of the File Owner, rather than the class of the View. To set this, I had to click the "backwards play" icon in the lower left corner of the Interface Builder window, and options then appeared that isolated the characteristics of the File Owner, the First Responder, and the View. Clicking on the first one (a large transparent box), enabled me to then set its custom class as suggested above.
I had the same problem, but a different solution was called for. The problem in this case was the class of the File Owner was not connected to xib file.
I ran into something very similar tonight, with a Swift UIViewController subclass. In this case, none of the above fixes worked, but reordering my code a bit did. Net-net, having an extension to the subclass occur before the subclass's definition itself in the same file seems to confuse XCode, despite compiling fine; the fix was to place the extensions after the subclass's definition.
I've posted the details in an answer to this similar question.
In my case , the designated initializer - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil in ***ViewController class was implemented so even if when I call other initializer to initialize the object ,the designated initializer will be called .
So to resolve this problem checking wether the - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil is also a proper way.
My problem was in wrong classes. I used custom .xib for my custom view.
Correctly it has to be set like here:
View shouldn't have a class
Class which is used with the .xib is set in File's Owner tab
Outlets are connected to File's Owner and not to the View.
Just had the same error in my project, but different reason. In my case I had an IBOutlet setup with the name "View" in my custom UITableViewController class. I knew "view" was special because that is a member of the base class, but I didn't think View (different case) would also be a problem. I guess some areas of Cocoa are not case-sensitive, and probably loading a xib is one of those areas. So I just renamed it to DefaultView and all is good now.
select the files owner and goto open the identity inspecter give the class name to which it corresponds to. If none of the above methods works and still you can't see the view outlet then give new referencing outlet Connection to the File's Owner then you can able to see the view outlet. Click on the view Outlet to make a connection between the View Outlet and File's owner. Run the Application this works fine.
In my case, the view was not viewed in xib.
in xib the View was size = none (4th tab right hand). I set size to Freeform and reload xCode.
view was appealed and I set the proper link to View.
If you have tried everything and you still get this error, try re-creating the class file from scratch but remember to select the "Also create XIB file" check box. This will auto link up a few items that are not linked when creating these files separately. After this is created, you can likely cut and paste everything onto the new XIB and it should work fine.
I am finding this issue specifically with creating files separately in Swift.
for me it happened, when
I have a ViewController class ( .mm/h ) associated with the Nib file,
UIView from this ViewController has to be loaded on the another view as a subview,
we will call something like this
-(void)initCheckView{
CheckView *pCheckViewCtrl = [CheckView instance];
pCheckView = [pCheckViewCtrl view];
[[self view]addSubview:pCheckView];
[pCheckViewCtrl performCheck];
}
Where
+(CheckView *)instance{
static CheckView *pCheckView = nil;
static dispatch_once_t checkToken;
dispatch_once(&checkToken, ^{
pCheckView = [[CheckView alloc]initWithNibName:#"CheckView" bundle:nil];
if ( pCheckView){
[pCheckView initLocal];
**[pCheckView loadView];**
}
});
return pCheckView;
}
Here loadView was missing,,, adding this line resolved my problem.
I had the same problem, I figured out and it is because of i had ticked "Static cells" in the properties of Table View under Content option. Worked when it changed to "Dynamic Prototypes". Screenshot is below.
I had a similar problem with Xcode 9.3, and setting "Module" under the "File Owner's" attribute inspector to the project module fixed this for me.
Open your storyboard file where your viewController exists, or XIB related file with textEdit.app and check if the storyboard or XIB name is the same of your viewController, then change it, save and reload/restart Xcode.
If you're using a custom init method, check that you're returning something valid. I ran into a piece of code that crashed on something like this:
- (id)init {
self = [super init];
if (self) {
CustomController *controller = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(className) owner:self options:nil];
} return self;
}
In another class, the controller was created like so:
CustomController *controller = [[CustomController alloc] init];
The problem is that in the init method, self hasn't changed and should look like this instead:
- (id)init {
self = [super init];
if (self) {
CustomController *controller = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(className) owner:self options:nil];
[controller viewDidLoad];
self = controller;
} return self;
}

Resources