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.
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 wonder how implementing two different ViewControllers and their own classes on the same page. Feed page both of them, and then I wanna pass them using left/right swipe gesture. But I don't know exactly how combining these pages together.
If someone explain as detailed It would be great.
Update
I have added Bridging header and your lines of codes, after editing new ViewControllers and identifier. But When I run and open this view, application stopped with below error.
All my views WishVC, TestVC1, TestVC2 are blank, there are no object.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
I am using an UITableView for showing some data. Now when an user tap on a cell I appended a new cell just below the taped cell to show some more extra information. Everything is working fine. It's has two sections. Now if I tap on a cell of section 1 it's append a new cell as it should be. Then I do down scroll and the appended cell & it's parent cell is going out of the visible rect. And when I do up scroll it's shows back. No issue. But the problem is if I scroll up very fast it got crashed on the below line.
UITableViewCell *parentCell=[tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:[indexPath row]-1 inSection:[indexPath section]]];
In console it shows
***** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 5 beyond bounds [0 .. 4]'
If I scroll slowly it's works fine only got crashed if I do it fast. And very strange is if I do the same for section 0. It's not got crashed. Guys please help me. I already spent lot of time to figure out this but fail. Thanks in advance.
The -1 in [indexPath row]-1 is almost certainly wrong; the row is zero-based and so are your data structures (well they are if you keep your data in an NSMutableArray or somesuch).
However this doesn't tally with the exception "5 is greater than 4", so I'm assuming you are making "+1" and "-1" adjustments here and there which is breaking your app.
I'm pretty sure you don't have to make these adjustments at all, however I cannot tell for certain without seeing more code.
I've created a table view based on a feed that contains what is essentially a number of form type elements. Simplified think of it as containing two types of elements textboxes and messages. Textbox type cells should contain UITextFields and Message type cells contain a non editable UITextArea.
I have created a custom cell to handle each of the types and render them into a table. So far so good.
The client has requested a prev/next/done inputAccessoryView like the one that safari uses for html forms. A bit of work later I've got that up and running, I add some functionality that makes prev/next skip over message type cells and only call makeFirstResponder when it finds a textbox type cell. Still things seem to be going smoothly.
Then I added, in testing, a really long message to test my row height setting code. When I try to prev or next over this message cell it fails with a:
2012-02-21 11:34:36.642 MobileMarketing[52410:13a03] -[ContactFormTableViewController selectUpdate:]: unrecognized selector sent to instance 0x89802f0
2012-02-21 11:34:36.643 MobileMarketing[52410:13a03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ContactFormTableViewController selectUpdate:]: unrecognized selector sent to instance 0x89802f0'
I assume this is because the target field on the far side of the message and now offscreen has been dequeued. I'm reading up on that. But a long way around for a simple question. Does anyone have a good technique for dealing with this problem?
If I'm understanding your problem correctly, you may be able to solve this using scrollToRowAtIndexPath:atScrollPosition:animated as seen here: https://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITableView_Class/Reference/Reference.html.
If you scroll to the next cell, you can guarantee it exists before you try to makeFirstResponder.