PDA

View Full Version : App Crashes after reload data. no crash report




Cdub16
Dec 3, 2009, 05:00 PM
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.



dejo
Dec 3, 2009, 06:17 PM
if you need me to post the code just tell me.
Yes, please. At least post your tableView:cellForRowAtIndexPath: method.

Cdub16
Dec 3, 2009, 06:27 PM
- (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

Cdub16
Dec 3, 2009, 06:30 PM
i was releasing cell label.
idk why it was screwing up everything


thanks tho. any other suggestions just say

dejo
Dec 3, 2009, 06:31 PM
- (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;
}

You're releasing cellLabel, which you never allocated. I'd try this instead:
// Set up the cell...
cell.textLabel.text = [assignments objectAtIndex:indexPath.row];
return cell;
Also, make sure you have a basic understanding of memory management.