1.callBackObject.h
To add delegation pattern to your object, simply add @Protocal ... @end before @interface tag. In @Protocal ... @end, add @reqiured and @optional tag and declare required methods and optional methods.
Must implement a property:
@property (nonatomic,weak) id <CallBackObjectDelegate> delegate;
In callBackObject.m , instance methods use this property to call delegate method.
Here I implement a class method:
+ ( CallBackObject* ) obejectWithDelegate : (id) delegate;
It is for convenience, because sometimes I might forget to assign delegate when using delegation object.
2.callBackObject.m
3.ViewController.h Must add callbackobjectdelegate
4.ViewController.m
Must implement
-(NSString *) aMustCallBackToProceed : (NSString * ) message;
To add delegation pattern to your object, simply add @Protocal ... @end before @interface tag. In @Protocal ... @end, add @reqiured and @optional tag and declare required methods and optional methods.
Must implement a property:
@property (nonatomic,weak) id <CallBackObjectDelegate> delegate;
In callBackObject.m , instance methods use this property to call delegate method.
Here I implement a class method:
+ ( CallBackObject* ) obejectWithDelegate : (id) delegate;
It is for convenience, because sometimes I might forget to assign delegate when using delegation object.
2.callBackObject.m
3.ViewController.h Must add callbackobjectdelegate
4.ViewController.m
Must implement
-(NSString *) aMustCallBackToProceed : (NSString * ) message;