0

So I have a TableViewController, when certain cell pressed it goes to my DetailViewController to display more details about the pressed cell.

On this DetailViewController, I would like to add a button and when this button gets pressed a "CHECKMARK" will add to its cell from TableViewController and goes back to TableViewController. How would you do that?

I already added an IBAction for my button but I don't know how I would implement that yet..

Please speak in layman's term as much as possible because I'm not that yet very familiar with iOS Programming. Thank you so much.

Rhenzzz
  • 47
  • 2
  • 9

1 Answers1

0

You can use protocol for message transfer.

In your detailViewController create protocol,

@protocol yourDetailViewControllerDelegate <NSObject>

- (void)yourDetailViewController:(YourDetailViewController *)controller didSelectObject:(YourObject *)object;

@end

and create delegate object,

@property (nonatomic, weak) id<yourDetailViewControllerDelegate> delegate;

Then in your tableViewController implement the delegate method,

- (void)yourDetailViewController:(YourDetailViewController *)controller didSelectObject:(YourObject *)object {

  // code for add check mark

}

In your button action,

- (void)buttonAction {
  // Call the delegate method
  [delegate yourDetailViewController:self didSelectObject:changedObject];

}
Anusha Kottiyal
  • 3,855
  • 3
  • 28
  • 45