Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Self-Destructing Message iPhone App Capturing Photo and Video Using UIImagePickerController Adding Recipients

[removeAllObjects] doesn't work

After i cancel sending, i go back to Camera tab but i find the recipients still checked. No Errors.

- (IBAction)cancelButton:(id)sender {
    self.image = nil;
    self.videoFilePath = nil;
    [self.recipients removeAllObjects];
    [self.tabBarController setSelectedIndex:0];
}

2 Answers

Patrick Cooney
Patrick Cooney
12,216 Points

I don't have my code for this project in front of me and wont for a couple hours, but if I remember correctly you need to also set the accessoryView to none.

-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];

    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

    PFUser *user = [self.friends objectAtIndex:indexPath.row];


    if (cell.accessoryType == UITableViewCellAccessoryNone) {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
        [self.recipients addObject:user.objectId];
    }
    else {
        cell.accessoryType = UITableViewCellAccessoryNone;
        [self.recipients removeObject:user.objectId];

    }

}

I did that.