iPhone app is crashing — error-message sent to deallocated instance 0xa58a950

吃可爱长大的小学妹 提交于 2020-01-14 06:01:27

问题


I n my iPhone app, I have implemented sidebar i.e. JTRevealSideBar to show the side bar on left side like facebook app But, the problem is it was crashing after clicking on the sidebar tableview for 1st index but for other index it is perfectly working

Crash Log [sidebarViewController:didSelectObject:atIndexPath:]: message sent to deallocated instance 0xa58a950

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (self.sidebarDelegate) 
        {
        SALSideBarViewCell * cell = (SALSideBarViewCell*)[tableView cellForRowAtIndexPath:indexPath];
        NSObject *object = cell.titleLabel.text;

        [self.sidebarDelegate sidebarViewController:self didSelectObject:object atIndexPath:indexPath];
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"sidecell";
NSString * cellText;

SALSideBarViewCell * salcell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (salcell == nil) {
    salcell = [[[SALSideBarViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    tableView.separatorColor = [UIColor clearColor];
    if ([UIHelper isPad]) {
        UIView *cellBackView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 60)] autorelease];
        cellBackView.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"sidebar_cell_pad.png"]];
        salcell.backgroundView = cellBackView;
    } else {
        UIView *cellBackView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 40)] autorelease];
        cellBackView.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"sidebar_cell.png"]];
        salcell.backgroundView = cellBackView;
    }
}

if ( indexPath.section == 0 ) {
    cellText = [dataArray objectAtIndex:indexPath.row];
    if ( indexPath.row == 0 && self.slideDecksCount > 0 )
        [salcell setValue:[NSString stringWithFormat:@"%d", self.slideDecksCount]];
    else if ( indexPath.row == 1 && [[[RDStore sharedInstance] publicUsers] count] > 0 )
        [salcell setValue:[NSString stringWithFormat:@"%d", [[[*** sharedInstance] ***] count]]];
    else if ( indexPath.row == 2 && [[[RDStore sharedInstance] premiumUsers] count] > 0 )
        [salcell setValue:[NSString stringWithFormat:@"%d", [[[*** sharedInstance] ***] count]]];
    else if ( indexPath.row == 3 && [[[RDStore sharedInstance] tagCloudlabels] count] > 0 )
        [salcell setValue:[NSString stringWithFormat:@"%d", [[[*** sharedInstance] ***] count]]];
    else if ( [dataArray count] > 4 && indexPath.row == 4 && self.jsonDecksCount > 0 )
        [salcell setValue:[NSString stringWithFormat:@"%d", self.jsonDecksCount]];
}
else {
    cellText = [services objectAtIndex:indexPath.row];
}
salcell.titleLabel.text = cellText;
return salcell;

}

Please let me know where the mistake is Thanks

来源:https://stackoverflow.com/questions/19152427/iphone-app-is-crashing-error-message-sent-to-deallocated-instance-0xa58a950

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!