开发者

App crashes at cellForRowAtIndexPath

开发者 https://www.devze.com 2022-12-16 11:50 出处:网络
My app crashes when I scroll the UITableView over the first cell or the last cell! Why this is happening? I add with addObject:name the objects of the UItableview . This is the code I use at cellForRo

My app crashes when I scroll the UITableView over the first cell or the last cell! Why this is happening? I add with addObject:name the objects of the UItableview . This is the code I use at cellForRowAtIndexPath. Help please! I have been trying to figure out what is going wrong hours!

- (UITableViewCell *)tableView:(UITableView *)tableView 
         cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString * DisclosureButtonCellIdentifier = 
    @"DisclosureButtonCellIdentifier";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: 
                             DisclosureButtonCellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWi开发者_StackOverflow社区thStyle:UITableViewCellStyleDefault 
                                       reuseIdentifier: DisclosureButtonCellIdentifier]
                autorelease];
    }
    NSUInteger row = [indexPath row];

 NSString *rowString =nil;

    rowString = [list objectAtIndex:row];

 cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
    [rowString release];
    return cell;


You are calling [rowString release]; but you never retained it.


Is it throwing an exception - my guess is the index is not set:

rowString = [list objectAtIndex:row];

Can you set a breakpoint on this line and dump the "list"?

0

精彩评论

暂无评论...
验证码 换一张
取 消