App Crashes after reload data. no crash report

Discussion in 'iOS Programming' started by Cdub16, Dec 3, 2009.

  1. macrumors member

    Joined:
    May 30, 2008
    #1
    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.
     
  2. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Yes, please. At least post your tableView:cellForRowAtIndexPath: method.
     
  3. thread starter macrumors member

    Joined:
    May 30, 2008
    #3
    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
     
  4. thread starter macrumors member

    Joined:
    May 30, 2008
    #4
    Nevermind, i got it

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


    thanks tho. any other suggestions just say
     
  5. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    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.
     

Share This Page