Question

My delegate:

@class UpdateUserSummary;
@protocol UpdateSummaryDelegate <NSObject>

- (void)updateSummaryDidCancel:(UpdateUserSummary*)controller;
- (void)updateSummaryDone:(UpdateUserSummary*)controller;

@end

at interface :

@interface UpdateUserSummary : UIViewController
@property (nonatomic, weak) id<UpdateSummaryDelegate> delegate;
@end


- (IBAction)done:(id)sender {
    [self.delegate updateSummaryDidCancel:self];
}

Response from delegate:

-(void)updateSummaryDidCancel:(UpdateUserSummary *)controller
{
    // just close modal vc
    [self dismissViewControllerAnimated:YES completion:nil];
 }
Was it helpful?

Solution 2

@protocol MUpdateSummaryDelegate;

@interface MUpdateSummary : NSObject

@property (assign) id<UpdateSummaryDelegate> delegate; //You need this

@end


@protocol UpdateSummaryDelegate <NSObject>

-(void)updateSummaryDidCancel:(UpdateUserSummary *)controller;

@end

In the class where you are calling delegate, you need to set delegate.

MUpdateSummary *mUpdateSummary = [[MUpdateSummary alloc] init];
mUpdateSummary.delegate = self;

OTHER TIPS

Use this, UpdateUserSummary.delegate = self; where you are calling delegate in you implementation class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top