Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6745249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:10:55+00:00 2026-05-26T12:10:55+00:00

i was implementing the table view programmatically, where i set property of mSelectedSubUnitIndex of

  • 0

i was implementing the table view programmatically, where i set property of mSelectedSubUnitIndex of (NSIndexPath) type as non atomic and retain and synthesized in .m . When i load my tableviewcontroller then method:

(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath
:(NSIndexPath    *)indexPath
{
CGFloat height = 0.0;
    SubUnit *subUnit = (SubUnit*)[mSubUnitsArray objectAtIndex:indexPath.row];
NSArray *subUnitExercises = [self sortArray:[subUnit.subUnitExercise allObjects]];
  NSLog(@"mSelectedSubUnitIndex.row........%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;   
} 

run quite fine. When i return back to my tableviewcontoller from other controller then it crashes(object message send) at same method on line number 5 at NSLog, and give exception at method at [self.tableView reloadData];. It is resolved by commenting[self.tableView reloadData];.

-(void)viewDidAppear:(BOOL)animated

{
DebugLog(@"start");
    //[self.tableview reloadData];

execountarray=[[NSMutableArray alloc]init];
for(int k=0;k<[mSubUnitsArray count];k++)
{
    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];  

}

didSelectRowAtIndex

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath 
*)indexPath 
{
DebugLog(@" -start- \n");
mSelectedSubUnitIndex = indexPath;
SubUnit *subUnit = (SubUnit*)[mSubUnitsArray objectAtIndex:indexPath.row];
NSArray *subUnitExercises = [self sortArray:[subUnit.subUnitExercise allObjects]];
if([subUnitExercises count]!=1) 
{
    NSArray* paths = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:  
[mSelectedSubUnitIndex row] inSection:0]];
    [tableview beginUpdates];
    [tableview deleteRowsAtIndexPaths:paths   
withRowAnimation:UITableViewRowAnimationFade];
    [tableview insertRowsAtIndexPaths:paths  
withRowAnimation:UITableViewRowAnimationFade];
    [tableview endUpdates];
}
else
{
    //SubUnit *subUnit = (SubUnit*)[mSubUnitsArray objectAtIndex:  
[mSelectedSubUnitIndex row]];
    SubUnit *subUnit = (SubUnit*)[mSubUnitsArray objectAtIndex:indexPath.row];
    NSArray *subUnitExercises = [self sortArray:[subUnit.subUnitExercise 
 allObjects]];
    if ([subUnitExercises count] > 0) {
        SubUnitExercise *subUnitExercise = [subUnitExercises 
 objectAtIndex:0];
        [self loadSubUnitExercise:subUnitExercise];
    }
}
  }

this is running on iOS 4 but when i build through Xcode version 4.2 and iOS 5 (released oct-12, 2011) then it crashes. Can’t figure out the problem. help me out!!

cellForRowAtIndex method

now i am getting exception at if-statement at mSelectedsubunitindex.row when i scroll, but i resolved only checking that if (indexPath.row){}, and also row remain selected when i return bad to my tableview controller

- (void)tableView:(UITableView *)tableView willDisplayCell:
 (UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
 {    
DebugLog(@"-start- \n");
SubUnit *subUnit = (SubUnit*)[mSubUnitsArray objectAtIndex:indexPath.row];
NSArray *subUnitExercises = [self sortArray:[subUnit.subUnitExercise allObjects]];
NSString *str1 = [[subUnit performSelector:@selector(title)]copy];
if ([str1 isEqualToString:@"1. was/were"]) 
{
    global = str1;
}
//if(indexPath.row==mSelectedSubUnitIndex.row)
if(indexPath.row)
    {

    if ([subUnitExercises count] != 1)
    {
      SubUnit *subUnit = (SubUnit*)[mSubUnitsArray objectAtIndex:            
      [mSelectedSubUnitIndex row]];
        NSArray *subUnitExercises = [self sortArray:
        [subUnit.subUnitExercise allObjects]];
        SubUnitCell *subUnitcell = (SubUnitCell*) cell;

        mCellSubTopicLabel.text = subUnit.title;

        if([myNotes count] == 0)
        {
            NSNumber *isDone = [[subUnitExercises objectAtIndex:1] isDone];

            [subUnitcell setExer2Done:NO];
            mExer2Checkbox.image = [UIImage imageNamed:[isDone boolValue]?   
            kExerciseCheckmark :kExerciseWrongmark];

            isDone = [[subUnitExercises objectAtIndex:0] isDone];
            [subUnitcell setExer1Done:NO];
            mExer1Checkbox.image = [UIImage imageNamed:[isDone boolValue]?
             kExerciseCheckmark :kExerciseWrongmark];

        }
        else 
        {
            NSNumber *isDone = [[subUnitExercises objectAtIndex:1] isDone];

            [subUnitcell setExer2Done:[isDone boolValue]];
            mExer2Checkbox.image = [UIImage imageNamed:[isDone boolValue]?
            kExerciseCheckmark :kExerciseWrongmark];
            isDone = [[subUnitExercises objectAtIndex:0] isDone];
            [subUnitcell setExer1Done:[isDone boolValue]];
            mExer1Checkbox.image = [UIImage imageNamed:[isDone boolValue]?
            kExerciseCheckmark :kExerciseWrongmark];        
        }
        [subUnitcell.contentView addSubview:mCellSubTopicContentView];

}

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:10:55+00:00Added an answer on May 26, 2026 at 12:10 pm

    For some reason NSIndexPath assignment (=) and equality(==) is not working in IOS5. I have solved the problem using self before any NSIndexPath object e.g.

    self.mSelectedSubUnitIndex
    

    There is another way solving this assignment using copy like this:

    anIndexPath = (NSIndexPath*) [anotherIndexPath  copy];
    

    Equality works in same way. Like:

    if([self.mSelectedSubUnitIndex isEqual:anotherIndexPath])
    {
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am implementing a TableViewController. I would like to create the table view with
I am implementing a table index view and amazed to see how my table
I am implementing two navigation bars with a table view underneath both of the
in my program, I'm implementing a custom view, a bit like a table view.
It's almost the first time I'm implementing a table view in my code. I
I am implementing a search bar controller to search a table view. The below
I am implementing my custom table view controller. The issue I am facing is
I'm implementing a table with a fixed header using this kind of setup: <div
I'm looking for good patterns for implementing a paged table of results in ASP.NET
I'm implementing an interface that has functionality similar to a table that can contain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.