07-21-2023, 06:33 PM
I have a theoretic question. Now İ'm reading Apple's [ViewController][1] guide.
They wrote:
> When it comes time to dismiss a presented view controller, the
> preferred approach is to let the presenting view controller dismiss
> it. In other words, whenever possible, the same view controller that
> presented the view controller should also take responsibility for
> dismissing it. Although there are several techniques for notifying the
> presenting view controller that its presented view controller should
> be dismissed, the preferred technique is delegation.
But I can't explain, why I have to create a protocol in presented VC and add delegate varible, create delegate method in presenting VC for dismissing presented VC, instead of a simple call in **presented** view controller method
`[self dismissViewControllerAnimated:NO completion:nil]`?
Why is the first choice better? Why does Apple recommend it?
[1]:
They wrote:
> When it comes time to dismiss a presented view controller, the
> preferred approach is to let the presenting view controller dismiss
> it. In other words, whenever possible, the same view controller that
> presented the view controller should also take responsibility for
> dismissing it. Although there are several techniques for notifying the
> presenting view controller that its presented view controller should
> be dismissed, the preferred technique is delegation.
But I can't explain, why I have to create a protocol in presented VC and add delegate varible, create delegate method in presenting VC for dismissing presented VC, instead of a simple call in **presented** view controller method
`[self dismissViewControllerAnimated:NO completion:nil]`?
Why is the first choice better? Why does Apple recommend it?
[1]:
[To see links please register here]