UITableView Exception After Rendering - ios

I'm getting this error when a load a UITableView. It's occurring after the nib loads, but before either the cellForRowAtIndexPath, numberOfRowsInSection or other related methods are called.
The object it is backed onto is empty, but it still occurs when there is an object there (it's an NSMutableArray).
*** Assertion failure in -[_UITableViewUpdateSupport _computeRowUpdates], /SourceCache/UIKit/UIKit-1860.2/UITableViewSupport.m:263
2011-08-12 12:24:00.616 WheresNext[684:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unable to resolve row for index path: <NSIndexPath 0x1d18f0> 2 indexes [0, 1]'
This doesn't however occur in the Simulator, only on devices.
Any ideas?

This error occurs often when it exists an inconsistency between the rows you add to your TableView and the number of rows return by tableView:numberOfRowsInSection:.

Related

Delete a UICollectionViewCell from the cell

I have a method that calls the below code within a UICollectionViewCell. The cell has a reference both to the UICollectionView and to the array that it is based off of. The below code fails with the error:
2014-11-20 13:41:08.976 MyApp[954:304515] *** Assertion failure in -[UICollectionView _endItemAnimations], /SourceCache/UIKit/UIKit-3318.16.14/UICollectionView.m:3917
2014-11-20 13:41:08.978 MyApp[954:304515] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (1) must be equal to the number of items contained in that section before the update (1), plus or minus the number of items inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).'
*** First throw call stack:
(0x22f09d67 0x30768c77 0x22f09c3d 0x23bdcaa9 0x2656863d 0xe8e50 0xe8fa8 0x2680bcc1 0x23c10dc9 0x22ed0517 0x22ed0099 0x22ece303 0x22e1b981 0x22e1b793 0x2a1f4051 0x2640d981 0x1138f4 0x113930 0x30d04aaf)
libc++abi.dylib: terminating with uncaught exception of type NSException
The Code
//Resolves cell deletion
func deleteMe()
var path = collectionView.indexPathForCell(self)!
collectionArray.removeAtIndex(path.row)
collectionView.deleteItemsAtIndexPaths([path])
}
How do I delete this cell?
In this case, when assigning collectionArray or collectionView (I didn't test to see which, but my bet is on collectionArray) it was not an inout reference, but rather a copy. Array's have some odd functionality like this for performance issues. If I passed in a reference to the whole parent view (serviceView) and accessed using
serviceView.collectionArray.removeAtIndex(path.row)
serviceView.collectionView.deleteItemsAtIndexPaths([path])
it works fine. The datasource and the displayed cells were mismatched because the array was not being edited, a copy was.

MZFormSheetController Assertion failure

I'm using Custom AlertView MZFromSheetController, but it gives me the following Exception
*** Assertion failure in -[MZFormSheetController presentAnimated:completionHandler:], /Users/dt4it/Documents/SucessQuotes11/SucessQuotes/MZFormSheetController.m:418
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempting to begin a form sheet transition from to while a transition is already in progress. Wait for didPresentCompletionHandler/didDismissCompletionHandler to know the current transition has completed'
Could anyone tell me how to solve this?
Ensure you aren't calling the presentation method multiple times, I just hit this exact issue and found that the code was being called 4 times. Reducing it down to 1 (as it should be) fixed up the Assertion failure Exception.

Assertion failure in -[NSIndexPath row] with AppList dataSource

See update below.
I'm writing a tweak and am using AppList. I am hooking into spotlight and creating a table off all installed applications. I am trying to use the dataSource to get the information (display identifier etc). The problem is if dataSource is defined... I get the following error:
SpringBoard[1622] <Warning>: *** Assertion failure in -[NSIndexPath row], /SourceCache/UIKit/UIKit-2380.17/UITableViewSupport.m:2680
SpringBoard[1622] <Warning>: ***** AltKeyboard Uncaught Exception: Invalid index path for use with UITableView. Index paths passed to table view must contain exactly two indices specifying the section and row. Please use the category on NSIndexPath in UITableView.h if possible. *****
or
SpringBoard[1890] <Warning>: ***** AltKeyboard Uncaught Exception: *** -[__NSArrayM objectAtIndex:]: index 2 beyond bounds [0 .. 1] *****
SpringBoard[1890] <Error>: *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 2 beyond bounds [0 .. 1]'
*** First throw call stack:
If dataSource is not defined and I use fake data (test name), the table is generated fine. When I print the dataSource there are only two items in it.
Ryan Petrich, on IRC, seemed to suggest that I was doing everything completely wrong but wasn't much help after that. Perhaps I am going about solving this problem incorrectly?
Code: http://pastebin.ca/2457626
Repository: https://github.com/twodayslate/ListLauncher
edit/update!
dataSource is giving me problems. It isn't fetching the same number of apps and thus I am getting index errors and the like. I have over 200 apps but dataSource is only fetching 2.
The following code gives no errors but only displays 2 items: http://pastebin.ca/2458961
edit!
I changed it so I just use ALApplicationList. I am able to get all the applications listed. However, when I attempt to scroll through the table, it crashes. Sorting and creating the list is really slow so I believe that might be causing the problem. I'm no pro at obj-c so I'm sure there is a better way than what I am doing. http://pastebin.ca/2459318
Your problem is twofold. First, UITableView expects to be handed index paths containing both a row and a section, where you've provided it with only a row. Second, you cannot expect unchecked array access to succeed 100% of the time, so bounds check whatever access calls you might be using. It also wouldn't hurt to use some retains in the iVar assignments you've got in your code unless you don't need to hold a reference to it (but it looks like you do).
I figured out an alternative solution to ALDataSource. I sorted ALApplicationList.applications. The problem was that the instance of the sorted NSArray would keep disappearing. So I did [values retain] and everything worked! Reinitializing the sorted values was too slow and would crash the device.
Here is the working code that successfully lists all the apps: http://pastebin.ca/2459778

When clicking a cell, my app throws a NSInternalInconsistencyException

I am kind of a novice to programming and I thought I could find help here.
I am trying to make an app where when you click on the table view cell, it shows more detailed information. When you click the cell, the debug area opens up and I am given the following message:
2013-07-15 12:41:19.261 Chevy[3909:c07] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "ToB-mL-k5t-view-Ref-qb-iy9" nib but didn't get a UITableView.'
* First throw call stack:
(0x1c99012 0x10d6e7e 0x1c98deb 0x24a357 0xfbff8 0xfc232 0xfc4da 0x1138e5 0x1139cb 0x113c76 0x113d71 0x11489b 0x114e93 0x8ef23f7 0x114a88 0x470e63 0x462b99 0x462c14 0xca249 0xca4ed 0xad45b3 0x1c58376 0x1c57e06 0x1c3fa82 0x1c3ef44 0x1c3ee1b 0x1bf37e3 0x1bf3668 0x1affc 0x212d 0x2055)
libc++abi.dylib: terminate called throwing an exception
Does anyone know what I am doing wrong? I can post some of my code if you'd like.
The IBOutlet is either disconnected in the xib file for the tableView or connected to some unwanted element.

Crash with "Collection ... mutated while being enumerated"

I got this error after a crash:
malloc: *** error for object 0x75617b4: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
2013-02-05 19:15:44.950 BusinessIdea[3171:15e03] *** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSSetM: 0x72dc5c0> was mutated while being enumerated.'
I am not familiar with this error. Any idea what it could be?
The whole 'modified while being enumerated' error means you are probably trying to delete something from a set while iterating over it. For example
for(NSString *str in array){
if([str isequalToString:#"delete me"]){
[array removeObject:str]; //this will cause a problem,
}
}
If you want to use the fast enumeration loop, you need to build a list of items you want to remove, and then delete them after the iteration step. Alternatives are to use a traditional indexed for loop if you want to remove items in the loop body.

Resources