开发者

tableview reload in xcode 4.2

开发者 https://www.devze.com 2023-04-12 20:13 出处:网络
I had worked on an application. In which I have programmatically added the table view. This app is working properly in any xcode lower than 4.2 but when I tried to run it on xcode 4.2 release version

I had worked on an application. In which I have programmatically added the table view. This app is working properly in any xcode lower than 4.2 but when I tried to run it on xcode 4.2 release version it is giving problem at table view reload. How to fix the error. please provide me some solution to resolve the error in xcode 4.2.

-(void)viewDidAppear:(BOOL)animated{
    DebugLog(@"start");
    [self.tableView reloadData];

    execountarray=[[NSMutableArray alloc]init];
    for(int k=0;k<[mSubUnitsArray count];k++)
    {
      开发者_如何学JAVA  SubUnit *subUnit = (SubUnit*)[mSubUnitsArray objectAtIndex:k];
        NSArray *subUnitExercises = [subUnit.subUnitExercise allObjects];
        [execountarray addObject:[NSString stringWithFormat:@"%d",[subUnitExercises count]]];
    }

    ///////////////
    if (managedObjectContext){

        NSFetchRequest *request = [[NSFetchRequest alloc] init];
        NSEntityDescription *entity = [NSEntityDescription entityForName:@"TSubUnitExerciseProgress" inManagedObjectContext:managedObjectContext];
        [request setEntity:entity];

        // Order the events by creation date, most recent first.
        NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"editDate" ascending:YES];
        NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
        [request setSortDescriptors:sortDescriptors];
        [sortDescriptor release];
        [sortDescriptors release];

        // Execute the fetch -- create a mutable copy of the result.
        NSError *error = nil;
        NSMutableArray *mutableFetchResults = [[managedObjectContext executeFetchRequest:request error:&error] mutableCopy];
        if (mutableFetchResults == nil) {
            // Handle the error.
            myNotes = nil;
            [myNotes removeAllObjects]; 
        }
        else
        {
            [myNotes setArray: mutableFetchResults];
        }



        //NSLog(@"My notes count:--------unitviewcontroller--------------->%d",[myNotes count]);
        if([myNotes count] ==0)
        {
        setExer1Done:NO;
        setExer2Done:NO;
        }
        else 
        {
            NSLog(@"hey :P");

        }

    }
    [self.tableView reloadData];  

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //DebugLog(@"-start- \n");

    CGFloat height = 0.0;

    SubUnit *subUnit = (SubUnit*)[mSubUnitsArray objectAtIndex:indexPath.row];
    NSArray *subUnitExercises = [self sortArray:[subUnit.subUnitExercise allObjects]];



    NSLog(@"mSelectedSubUnitIndex:%d",mSelectedSubUnitIndex.row);
    NSLog(@"subUnitExercises:%d",[subUnitExercises count]);


    if (indexPath.row==mSelectedSubUnitIndex.row && [subUnitExercises count]>1) {
        height =CELL_EXPAND_HEIGHT ;
    }
    else {
        height = CELL_NORMAL_HEIGHT;
    }


    return height;
}

It is giving crash at NSLog(@"mSelectedSubUnitIndex:%d",mSelectedSubUnitIndex.row); May be it is not loading the indexpath. Here mSelectedSubUnitIndex is the index path. Thanku very much.

0

精彩评论

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

关注公众号