user6631314
user6631314

Reputation: 1968

IOS/Objective-C: Change object behind detail view of tableview programmatically

In a master tableview-detail view controller app, after loading a detail view, I would like to let the user view the detail for a different item from the tableview if they wish.

To do this, I pass two objects to the detail view in prepareForSegue and use one of them to load the view.

If I want, I am able to change individual items on the screen one by one, for example, by changing self.title = item.title to self.title = altitem.title. My question, is, whether there is a way to reload the entire view using the alternative object?

I have read that setNeedsDisplay should reload the whole view, but it is not changing the object behind the view or at least the view on the screen Here is my code currently:

//in prepareForSegue method in master tableview

destViewController.item=item;;
destViewController.altItem=altitem;

//in .h file of detail view

@property (nonatomic, strong) Items *item;
@property (nonatomic, strong) Items *altitem;

// in .m file of detailView

in viewDidLoad

self.title = item.title;

//my method to change object - NOT DOING ANYTING

-(void) reloadWithAltItem {
self.item = self.altitem;
[self.view setNeedsDisplay];
}

Thanks for any suggestions.

Upvotes: 1

Views: 76

Answers (0)

Related Questions