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

PizzaTray

macrumors newbie
Original poster
Oct 31, 2009
25
0
When i scroll my table its crash.
Code:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [self.list count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"Cell";
    
    CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[CustomCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }
	switch (indexPath.row) {
		case 0:
			cell.Label.text = [[self.list objectAtIndex:indexPath.row]retain];
			cell.imageView.image = [self.picArr objectAtIndex:0];
			break;
		case 1:
			cell.Label.text = [[self.list objectAtIndex:indexPath.row]retain];
			cell.imageView.image = [self.picArr objectAtIndex:0];
			break;
		case 2:
			cell.Label.text = [[self.list objectAtIndex:indexPath.row]retain];
			cell.imageView.image = [self.picArr objectAtIndex:0];
			break;
.
.
.
		default:
			break;
	}
	cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    return cell;

help someone?:confused:
 
It's probably not causing your crashes but you don't need to retain the values you're assigning to the label.

I'm pretty certain the property is not called 'Label' either. If you're on 3.x it's called 'textLabel'.
 
What do the crash logs say? Have you got an index out of bounds error? A memory error (e.g. overreleased object, etc)?

It looks as if there is not enough information visible to be able to concretely determine the cause of the crash. It could be all manner of things. Check that your label is a UILabel, your imageView is a UIImageView, your pictures array contains UIImage objects, your list data array contains NSStrings. If any of these don't you could get a crash.

I noticed you are accessing a property of your custom table view cell called Label - did you mean to have capitals? Remember that objective-C is case-sensitive. The default label property since 3.0 is textLabel.

Why do you need the switch statement? Looks like you do the same thing regardless of row? The text is stored in your list data array so you don't need it.

I would get rid of the retains as well for the text - you are causing memory leaks here...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.