Reputation: 21039
I have a UIViewController
that the root in a UINavigationController
. What I'm doing there is I am instantiating another UIViewController
of the same type, setting some properties and pushing it on top of the stack.
The problem here is that the parent view controller is also changing its property.
Here's how I'm doing it:
RootViewController *rootViewController = [[RootViewController alloc] initWithRequest:request];
[self.navigationController pushViewController:rootViewController animated:YES];
Why is this happening? Isn't this creating a new instance of the view controller and copying the same exact properties into a different object instance?
Upvotes: 0
Views: 708
Reputation: 119272
Both view controllers now have a pointer to the same request
object. Any changes you make are reflected in both controllers. You probably need to copy the request
object instead, if the controller is able to modify it.
Upvotes: 1