Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-21-2011, 06:22 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 122
architectpianist is on a distinguished road
Default Table View Crash after Deleting All Rows

Hi,
I have a table view that manages a list of objects, stored in a property self.equations. I have a button that pulls up an action sheet, which then clears the self.equations array and the table view.
Code:
-(void)clearEquations:(id)sender
{
	UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil 
															 delegate:self 
													cancelButtonTitle:@"Cancel" 
											   destructiveButtonTitle:@"Clear" 
													otherButtonTitles:nil];
	actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
	[actionSheet showInView:self.view];
}

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
	[actionSheet dismissWithClickedButtonIndex:buttonIndex animated:YES];
	if (buttonIndex == 0)
	{
		[self.equations removeAllObjects];
		[self refreshEquations];
		NSMutableArray *indexPaths = [NSMutableArray array];
		for (int i = 0; i < [equationLayers count]; i++)
			[indexPaths addObject:[NSIndexPath indexPathForRow:i inSection:0]];
		[tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationRight];
		if (self.delegate != nil)
			[self.delegate editedEquations:self.equations];
	}
}
The code runs fine if I use [tableView reloadData] instead of [tableView deleteRowsAtIndexPaths:withRowAnimation], but I'd like the row deletion to be animated. This code gives SIGABRT and in the console, it says:
Code:
*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1912.3/UITableView.m:1046
What does the warning mean, and how can I get around it?
Thanks!
architectpianist is offline   Reply With Quote
Old 12-21-2011, 06:45 PM   #2 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

I'm going to guess there is more to the error message than that. I suspect that refreshEquations is re-populating your array, so your objects count vs. number of rows is off.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 12-21-2011, 07:54 PM   #3 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 122
architectpianist is on a distinguished road
Default

Okay, here's the refreshEquations code:
Code:
-(void)refreshEquations
{
	if ([self.equations count] == 0)
	{
		//Show a view behind the table view with a label "no equations"
	}
	else
	{
		VSMathTypesetter *typesetter = [[VSMathTypesetter alloc] init];
		VSValueCalculator *calculator = [[VSValueCalculator alloc] init];
		[equationLayers removeAllObjects];

		//Populate equationLayers with CALayers from self.equations strings
	}	
}
It doesn't seem that self.equations is being modified by refreshEquations. A log at the end of the method shows an empty array. I'll take a look at the data count vs number of rows being off.
Thanks for the reply!
architectpianist is offline   Reply With Quote
Old 12-21-2011, 07:55 PM   #4 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

What is the rest of the crash message?
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 12-21-2011, 08:37 PM   #5 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 122
architectpianist is on a distinguished road
Default

Eureka! The error is here:
Code:
-(void)refreshEquations
{
	if ([self.equations count] == 0)
	{
		//Show a view behind the table view with a label "no equations"
	}
        //...
}
The problem is, the code is going through the first conditional without updating equationLayers. The update included removing all the objects. EquationLayers regulates the tableView, so you can see how equationLayers was persisting.
Thanks for your input!
architectpianist is offline   Reply With Quote
Reply

Bookmarks

Tags
delete, reload, sigabrt, uitableview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 393
13 members and 380 guests
7twenty7, AppsBlogger, Creativ, Dalia, David-T, Duncan C, HemiMG, heshiming, LunarMoon, Murphy, pbart, teebee74, Tomsky
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,127
Posts: 402,915
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:50 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0