i want know if it’s possible create a custom delegate in the AppDelegate class, like in this way for instance:
@protocol AppDelegateDelegate <NSObject>
- (void)finishSync:(BOOL)success;
@end
@interface AppDelegate : UIResponder <UIApplicationDelegate> {
@property (nonatomic, weak) id <AppDelegateDelegate> delegate;
@end
it’s possible create something like this? to notify the classes that are registered for this delegate?
EDIT
How i can use the Delegate? for example if i do this:
#import "AppDelegate.h"
@interface MasterViewController : UIViewController <AppDelegateDelegate>
@end
.m
@implementation MasterViewController
...
- (void)viewDidLoad {
AppDelegate *appController = (AppDelegate *)[[UIApplication sharedApplication] delegate];
appController.customDelegate = self;
}
in i stay only in that view works, but for example if i switch in SecondViewController that have the same code to implement the delegate, the delegate don’t works anymore neither in the MasterViewController…what i wrong?
Yes, That is fine. You can create delegates anywhere you want and use it anywhere by importing that class. There are no restrictions.