Reputation: 45
I have a singleton and it have a function -(void)repair;
I can write [Manager repair];
in every view controller in viewDidLoad, But since I have alot of view controllers I want that function to be called automatically without having to write it manually.
Is That possible, or the code that required for this method is going to take longer time than calling the method in each view?
NOTE: the reason I want to do this is to be able to enable and disable the function anytime I require without having to go back and delete it from each View.
Upvotes: 0
Views: 854
Reputation: 2474
you can swizzle UIViewController viewDidLoad method and put the repair call there. Take a look at http://nshipster.com/method-swizzling/
Upvotes: 0
Reputation: 3300
I see two ways to accomplish this:
Upvotes: 1