Search code examples
uitableviewviewwillappear

Mark tableview cell as completed when user user returns from subview


I am writing an application that teaches a user in lessons separated by sections. I have a tableview filled with custom tableview cells that have a check mark I want to unhide when the user completes the lesson and the lesson view is popped back to the table. Is there a way as my ViewWillAppear is called I can unhide the checkmark label in the specific tableview cell?


Solution

  • I usually store my information in an NSDictionary. In your case, when the user loads the lesson, you can add a BOOL value to an NSDictionary which will mean the lesson is complete, then in your cellForRowAtIndexPath: delegate, add this:

    if([plistDict objectForKey:@"kComplete"] == YES){
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    }else{
        cell.accessoryType = UITableViewCellAccessoryNone;
    }