UICollectionView dealloc assertion fail crash - ios

Totally stumped on this. When I dismiss my view controller which is being presented with a custom presentation/transition in iOS 8, I get a crash on private API with this error:
*** Assertion failure in -[UICollectionView dealloc], /SourceCache/UIKit/UIKit- 3318.16.21/UICollectionView.m:665
All I know is if I remove any of these:
[self.collectionView performBatchUpdates:^{
// append your data model to return a larger size for
// cell at this index path
} completion:nil];
then it doesn't crash.
But those methods ARE NOT being called on dealloc, dismiss, viewWillDisappear. Literally anything. It's like the invocations or messages are bing stuck in some dimension and called after the view is dismissed. But I can't log them and if I try to put in logic that prevents them being called in that case, it does nothing. Which kinda makes sense: they aren't actually BEING called.
UGH! Ideas?
Update:
I just got a crash with more info (tho still opaque)
malloc: *** mach_vm_map(size=2146844672) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Update 2:
I got it to stop crashing by wrapping some code in:
[self performAfterDelay:0 block:^{
//batch updates
}];

Related

UISearchController + UICollectionView error

I'm building an app that uses UICollectionView to display content. I added the UISearchController to section header and everything works just fine. However when I dismiss the search and than edit the first item (row 0, section 0) I got this error:
2014-08-19 18:18:37.415 Slick[28793:1772932] * Assertion failure in
-[SLCollectionView _updateWithItems:], /SourceCache/UIKit_Sim/UIKit-3232.3/UICollectionView.m:4343 2014-08-19
18:18:37.416 Slick[28793:1772932] CoreData: error: Serious application
error. An exception was caught from the delegate of
NSFetchedResultsController during a call to
-controllerDidChangeContent:. Attempt to delete item containing first responder that refused to resign with userInfo (null)
When I edit any other item first than everything is OK. The confusing thing is that I'm not even deleting the first item, just editing it. Do you guys have any idea what might cause this problem?
Looks like a bug in simulator. On real device it works as it should.

[Not A Type release]: message sent to deallocated instance in UITableView

I get a crash when quickly scrolling through a UITableView.
The crash is :
*** -[Not A Type release]: message sent to deallocated instance 0x1aded1c0
And the exception breakpoint indicates this as the source:
- (void)updateInfo:(Item*)item{
if (!item) {
return;
}
Program *prg = (Program *)item;
self.titleLabel.text = prg.title; // crash here
self.descriptionLabel.text = prg.item_description;
}
This method is inside the custom table view cell subclass and it is called when data from the internet is ready to be displayed in the cell.
I have never seen this kind of crash before...
What is the best way to fix it?
Reason:
As you scroll the tableview, the cells on top get released and when data comes from internet for those cell, they have already been released. So, change your logic. You generally receive this error when you try to access and update an object which has already been released. As you are saying that this method is inside your custom cell, so it clearly indicates that the cell is already released. That's why your app gets crashed when you try to update any view of that cell.
Solution:
Either you can reload your whole tableview or reload those specific cells when you receive data.
Where are you calling the method "updateInfo"? You should call this in cellForRowAtIndexPath. You should not store a reference to a cell and then call this.
When you get the data from your service you just call self.tableView reloadData (or perhaps reloadRowsAtIndexPaths if you know which row needs update and dont want a performance hit)

SIGABRT between loadView and viewDidLoad

I'm new to iOS development, and having trouble identifying the source of a SIGABRT. I've narrowed it down to something that happens during initialization of a UIViewController subclass, specifically between its loadView and viewDidLoad methods.
I narrowed it down with an NSLog call in each of those method overloads in my UIViewController subclass. However, I'm unable to get any more granularity from the debugger; I can't step into the [super loadView] method. Are there any techniques for debugging a SIGABRT other than NSLogs and stepping through with the debugger? Is there any way to see exactly from where the exception was thrown?
Program-specific details
This program uses Core Data; I created it following this tutorial. I believe the SIGABRT started happening after I ran through the "Relationships In Action" section, and was not happening before (I think I had a successful build at the end of the preceding section). Specifically, I can successfully add a Person, but PersonDetailTableViewController throws a SIGABRT between loadView and viewDidLoad.
I've tried deleting the app from the iPhone simulator, and also running a Product > Clean; neither had any effect.
Found the culprit. I had earlier incorrectly created an IBOutlet by ctrl+dragging from a Table View Cell's Text Field into my UITableViewController subclass. I manually deleted the code this created, but a connection remained in the Connections Inspector. Deleting that connection solved the problem -- no more SIGABRT.
It's unfortunate that Xcode sees the problem (see the exclamation mark in the attached image), but didn't tell me about it in any way except the mysterious SIGABRT....

App crashes on sudden navigation changes iOS

i am creating an iPhone application with tabbar controller. I have two tabs with tableview controller. In both tabs some web service calls are there and it updates the table contents. I am using a loading indicator and all the service calls are performing on background thread and UI updates on mainthread with waitUntilDone:YES. In normal case everything is working perfect.
But the issue is,if I do sudden changes of tabs repeatedly the app crashes with error message:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x382a62a3 0x3338d97f 0x381f1b75 0x1521f9 0x362fb545 0x362e030b 0x362f77c7 0x362b3803 0x312d1d63 0x312d1901 0x312d2835 0x312d221b 0x312d2029 0x362b98eb 0x3827b6cd 0x382799c1 0x38279d17 0x381ecebd 0x381ecd49 0x3a0ec2eb 0x363042f9 0xcd317 0xc0b70)
libc++abi.dylib: terminate called throwing an exception
I know, its because try to access values from NSArray where there is no contents. But, is there any common reason for this? I mean, if I do tab changes in normal speed there is no issue. But if I try to change the tabs, just after the loading indicator ends, the app crashes. I am not able to track this on the code. Crash is happening in main.m
Please share your ideas.
Update
The issue was happening in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
at
songTitle.text = [songTitleSH objectAtIndex:indexPath.row];
albumTitle.text = [albumNameSH objectAtIndex:indexPath.row];
artistName.text = [artistNameSH objectAtIndex:indexPath.row];
commentDateLbl.text = [playDateSH objectAtIndex:indexPath.row];
i am getting NULL values in these arrays, that caused the issue. So, how can I overcome this issue? Any idea?

iOS - Getting a weird error: unrecognized selector sent to instance on a UITableView

Introduction
In my current application I have a UITableView which holds custom cell objects. The custom UIViewCellObjects are simply subclassed from the standard UITableViewCell class. The custom cells holds information about running background uploads, and updates them with things like percentage done and so on.
The custom cell objects listens to NSNotifications from upload processes running in the background, and when they get a relevant notification, they simply update their own view controls with the new information (such as upload percentage).
Now when an upload process is done, I re-order the array of active upload objects and reload the tableview like this:
-(void) uploadFinished: (NSNotification*)notification
{
NSDictionary *userInfo = [notification userInfo];
NSNumber *uploadID = [userInfo valueForKey:#"uploadID"];
if (uploadID.integerValue == uploadActivity.uploadID)
{
[[ApplicationActivities getSharedActivities] markUploadAsFinished:uploadActivity];
[parentTable reloadData];
[self setUploadComplete];
}
}
Now this method takes place in the tableviewcell objects, and as you can see they call their owning UITableView to reload the data right after the array is sorted. The markUploadAsFinished method simply re-orders the array so any newly finished upload is put at the top, so it will appear this way in the UITableView.
The Problem
Now the problem I'm having is that when this method is called, I sometimes get the following error:
'NSInvalidArgumentException', reason: '-[CALayer tableView:numberOfRowsInSection:]: unrecognized selector sent to instance
I do not get it all the time, sometimes the entire process runs fine and finished uploads appear in the start of the UItableview, and at other seemingly random times it fails. I don't really have a clue what's going on here.
The custom cells are loaded from a .NIB file like this:
UploadCell *cell = [activeUploadsTable dequeueReusableCellWithIdentifier:#"UploadProgressCell"];
if (cell == nil)
{
[[NSBundle mainBundle] loadNibNamed:#"UploadCellView" owner:self options:nil];
cell = customCell;
}
Is there anyone who might have a clue about what's going on here?
EDIT
First of all, I have tracked down this error to appear right at the line where:
reloadData
is called inside of the custom cell objects.
Furthermore, it seems that the instance it sends methods to can change. I just got this error too:
'NSInvalidArgumentException', reason: '-[UIScrollViewPanGestureRecognizer tableView:numberOfRowsInSection:]: unrecognized selector sent to instance
I really have no idea what's going on here.
'-[CALayer tableView:numberOfRowsInSection:]: unrecognized selector sent to instance
You've got a bad pointer. It looks like your table's data source is being released while the table still exists. The table doesn't retain its data source because that could create a retain cycle. If you don't take care to keep the data source around while the table is using it, the table will can up with a pointer to an object that no longer exists. In this case, it looks like a CALayer object is subsequently being created at the same address. When the table later sends its "data source" a message to get the number of rows, that message is delivered to the layer, which (obviously) doesn't have a -tableView:numberOfRowsInSection: method, and the error results.
According to me you running the upload process method in background i think other thread than main thread. And according to my knowledge when you deal with UIKIT objects you have ruin on main thread.
But these problem not occur every time because some time you switch to other thread to main thread so its working fine and some time not. so that problem occur

Resources