Recently, I have been assigned to deal with crash reports and I found that there are a lot of crash report that come from 'NSInternalInconsistencyException' that are originated from 'UICollectionView'. The 2 reasons that were common are
'Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView dataSource is not set'
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for number of items in section 0 when there are only 0 sections in the collection view'
I was not able to reproduce the crash. I'm sorry that I am not able to post the code or the full crash report, but I will try my best to briefly explain the situation.
I have a UIViewController that is holding a UICollectionView. The UIViewController acts as the dataSource and delegate for the UICollectionView. And the dataSource and delegate are assigned in the storyboard.
First, I thought that somehow the dataSource disappear somewhere, which would have cause the crash. So I tried to force the crash by setting dataSource = nil, but as expected it did not crash. I also found a solution here which says to check if dataSource in layoutAttributesForElementsInRect is equal to nil or deal with it accordingly. I tried to force dataSource = nil in there, but still can't reproduce the problem (
UICollectionView and Supplementary View crash)
Is it possible that somehow the UIViewController that acts as a dataSource for the UICollectionView died somehow so UICollectionView does not have the dataSource? But wouldn't this be the same as UICollectionView.dataSource = nil, which would not crash the app anyway?
Would it help if I separate UIViewController and UICollectionViewDataSource and then assign the dataSource in the viewDidLoad?
I would greatly appreciate it if someone could point me to the right direction in solving this problem.
Thanks
Edited: found a similar problem here iOS 9: UICollectionView dataSource is not set However, there is no solution yet.
Related
i have reloaded the view that contains table view. But when i keep on rotating the table view frequently the app crashes saying:
Terminating app due to uncaught exception 'NSGenericException', reason: '8 Collection <__NSArrayM: 0x7fdd5d460250> was mutated while being enumerated.'
I have implemented a simple table view with its delegates.
Can anyone suggest what actually this means.
looks like on rotate you are reloading the dataSource and while doing so your array is not fully populated and you are trying to change the array while its still have a reference somewhere else.
so I have a problem with UITableView. I have self-sizing cells and one can actually change height as the UITextView inside changes. When I set the UITableViewController editing, I get an index out of bounds crash by the super.
The crash occurs on this line:
super.setEditing(editing, animated: animated)
Error I get is:
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndexedSubscript:]: index 7 beyond bounds for empty array'
This out of bounds crash is not caused by a line of code that I wrote since I checked every instance where I access an array and none of them are being called when the crash occurs. The exception breakpoint points to the above line too so I am convinced this has something to do with the default UITableViewController implementation of setEditing: animated:.
An interesting point is that this error only occurs when the resizable cell is in the table view. When I create the table view without it, there are no issues. There are also no issues if I keep the cell in but don't touch any of the constraints so that it doesn't change its height. This leads me to believe that somehow a cell that changes height "in real-time" causes this strange crash but since I can't see into UITableViewController implementation to find the line that causes a bug, I don't know how to handle this problem.
Thanks
EDIT
Turns out that a more precise cause for the crash is when a cell tries to change its height as a direct result of a change in editing. So for example, a cell that simply grows or shrinks due to a text view with beginUpdates() and endUpdates() shouldn't cause any problems. But expanding a cell when starting editing is when this issue arises.
I am trying to create a UITableView inside a UICollectionViewCell. My goal is to implement a tableview inside my CollectionViewCell and populate my tableView with simple data. I want to create pages of tableViews populated with different categories of data.
I thought it would be a relative easy task, however I am getting a Threat 1: signal SIGABRT error. The debugger is prints
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'-[TableViewMockUp.ViewController tableView:numberOfRowsInSection:]:
unrecognized selector sent to instance 0x100b07cc0'
I am not sure what this error is telling me. When I look inside my ViewController I don't have a tableView numberOfRowsInSection method.
I have the project on Git if you want to take a look: https://github.com/cyrilivargarcia/TableViewMockUp
Below is a snapshot of my ViewController class
This is a snapshot of my CollectionViewClass which is where I created my TableViews.
Any idea on how I can resolve this problem?
-[TableViewMockUp.ViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x100b07cc0
I am not sure what this error is telling me. When I look inside my
ViewController I don't have a tableView numberOfRowsInSection method.
You've hit the nail on the head. The error is telling you "you don't have a numberOfRowsInSection method", and your reply is "I don't have one".
So... you just need to add that method to your view controller :)
Edit: After reviewing your code, to clarify for your specific case...
You had your TableView Delegate and DataSource connected to the wrong thing.
In IB, select your table view...
In the Utilities pane, select the Show Connections Inspector
Click the little "x" to delete the current Delegate and DataSource connections
Drag to the CollectionCell in the Document Outline tree
That should do it!
I have a Swift Application that has a table view, where inside each cell is another sublist which we keep in a second table view.
Each table view cell is composed of a Header area, another table view with sub items, and a footer area.
For some reason when you click right below the inner table view (highlighted in the image), it triggers an NSInvalidArgumentException with the following error and a long stack trace that isn't very helpful (I can provide it if someone thinks it will help).
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCellAccessibilityElement superview]: unrecognized selector sent to instance 0x7cd5f480'
I've set an exception breakpoint, but the debugger points to the AppDelegate on class initialization and provides no detailed info of where the error could be occurring.
I've experimented commenting out the code where I set the inner table view's delegate and datasource, and when I do so the error stops occurring, so I think that indicates that something is wrong with the inner table view.
The source code for the Custom Cells in question is located here
I'm assuming that the problem has something to do with accessibility, but I honestly have no idea what that even is, and have not been able to find related errors from my google searches. Thanks for the help!
First off,
You should not have a table view inside of another table view. This can cause problems, as you have found. I suggest that you adjust your code to insert cells dynamically and have multiple cell types.
As for your accessibility error, I would try toggling the accessibility checkbox on the storyboard under the Identity Inspector.
If you have any other questions, please let me know.
I have a UITableView that I populate with data from an array. It displays available networks, and populates the table view based upon its findings. I try and recall reloadData to the table view in one of my methods, but for some odd reason the app crashed with the error:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array'
To recreate the issue, I first scan for the networks. There are 2 available and they're just chilling. I connect to one, then I go to disconnect. I click disconnect, fire a reloadData to refresh the table view, then that is when the app crashes with the error. If I delete the reloadData call, it doesn't crash and goes along fine. This ties in with another question that I have about refreshing the table view to not display the network unless it's connected to it, I thought reloadData would work but it hates me. I'm at a loss of what to do to fix this bug and refresh properly.