NSInternalInconsistencyException Could not load nib in bundle
It looks like you're trying to instantiate a nib called ThemePickerController.nib and it isn't present. Is the nib included as a project member?
NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle
This error can occur when you rename files outside of XCode.
To solve it you can just remove the files from your project (Right Click - Delete and "Remove Reference").
Then after you can re-import the files in your project and everything will be OK.
Custom cell is causing a 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle:
If xib name is ParentTableViewCell.xib
Then you should do
itemsTable.register(UINib(nibName: "ParentTableViewCell", bundle: nil), forCellReuseIdentifier: "parentCell")
NSInternalInconsistencyException', reason: 'Could not load NIB in bundle:
see the difference of the following 3 ways to instantiate something from your Interface Builder work.
[NSStoryboard.mainStoryboard instantiateControllerWithIdentifier:@"youridentifier"];
NSStoryboard *launchScreen = [NSStoryboard storyboardWithName:@"LaunchScreen" bundle:NSBundle.mainBundle];
[launchScreen instantiateControllerWithIdentifier:@"yourIdentifier"];
[NSBundle.mainBundle loadNibNamed:@"SomeXibOrNib" owner:self topLevelObjects:nil];
In your example you try to load via the NSNib
method but you obviously meant the NSStoryboard
LaunchScreen.storyboard
With your code it is in fact looking for a Nib called "LaunchScreen.xib" or "LaunchScreen.nib" which the error tells you does not exist.
and your 2nd Question.
If your info.plist contains a proper entry for a MainStoryboard and this Storyboard is setup correctly, it will instantiate your Window with a ViewController as Root that was given.
Which means after the "Main" Window is loaded from that Storyboard you can access its rootViewController
property asking for its ViewController in charge.
UI/NSViewControllers come usually with a corresponding NS/UIView for free, but because subclassed Controllers may be different a typecast is needed to get rid of the warning telling you that. So to make sure the variable rootController will hold a pointer to an object of ViewController that has a property view it is typecasted.
Which works because the given RootViewController is of type "ViewController" and very likely a subclass of NS/UIViewController.
Typecasts also express you know the inheritance works because you guarantee that a view property does exist at runtime.
PS:it is always a bit confusing when chosen classnames are very simplified without any further indication which one is meant. ViewController could have been named "ANViewController" which will help you in larger projects when you have a lot different ViewControllers.
Exception : 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle..... in Swift 4
While registert nib, nibName shoudbe Cell namee means CustomCellOneCollectionViewCell
collectionViewOne.register(UINib(nibName: "CustomCellOneCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "cell1")
collectionViewOne.delegate = self
collectionViewOne.datasource = self
and in cellForItemAt
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell1", for: indexPath) as! CustomCellOneCollectionViewCell
return cell
}
Related Topics
How to Dismiss the iOS Keyboard
iOS Is It a Static or a Dynamic Framework
How to Get Server Response Data in Nsurlsession Without Completion Block
Steps to Create and Edit a Plist File in Xcode
Difference Between Static Function and Singleton Class in Swift
How to Make Uiview Animation Sequence Repeat and Autoreverse
How to Open the Imagepicker in Swiftui
Autolayout, Unable to Simultaneously Satisfy Constraints
Uirefreshcontrol with Uicollectionview in iOS7
How to Get Back "Allow Push Notifications" Dialog After It Was Dismissed Once
Creating a Percentage Based iOS Layout
How to Listen for All Notifications Sent to the iOS Nsnotificationcenter's Defaultcenter
Alamofire Download in Background Session
How to Use the Uisearchbar and Uisearchdisplaycontroller
Canopenurl - This App Is Not Allowed to Query for Scheme Instragram
Aligning Right to Left on Uicollectionview