Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Cdub16

macrumors member
Original poster
May 30, 2008
32
0
I have a table view that is initialized with a mutable array, and it is used with a uitableview. If the table view is used with just the array it is initialized with, it works fine. But if i add something to the array and call [tableView reloadData] on it and i scroll up and down the app crashes with nothing in the console. Xcode just says "Debugging terminated"

What could be causing this?!!

if you need me to post the code just tell me.
 
Here is the cellforrowatindex method

Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
	static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    
    // Set up the cell...
	
	NSString *cellLabel = [assignments objectAtIndex:indexPath.row];
	
	cell.textLabel.text = cellLabel;
	[cellLabel release];
	
    return cell;
}

if you need anything else just tell me
i was iffy on this method cuz this is my first main work with uitableview.
mostly used to work with mac not much iphone
 
Nevermind, i got it

i was releasing cell label.
idk why it was screwing up everything


thanks tho. any other suggestions just say
 
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
	static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    
    // Set up the cell...
	
	NSString *cellLabel = [assignments objectAtIndex:indexPath.row];
	
	cell.textLabel.text = cellLabel;
	[B][cellLabel release];[/B]
	
    return cell;
}
You're releasing cellLabel, which you never allocated. I'd try this instead:
Code:
// Set up the cell...
cell.textLabel.text = [assignments objectAtIndex:indexPath.row];
return cell;
Also, make sure you have a basic understanding of memory management.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.