I want to clarify the concept of delegate and protocols in objective c. So there are two types of protocols 1)Formal 2)Informal
In case of formal delegate.. what if the person has defined the protocol method but not ACTUALLY implemented it in both . i.e Class B is delegate of A and A has method WindowDidMove as optional...in that case. what would the behavior be??? and is it must to implement the delegate function in Class b. can't i just implement it in A and use it everywhere i want... and Conversely not define it in A, and give separate implementations in B or class C or D and use them however i want... please clarify this point – @class A;
@protocol ADelegate <NSObject>
@optional
- (BOOL)A:(A *)foo doSumfin:(BOOL)decide;
@end
@interface A : NSObject {
NSString *bar;
id <ADelegate> delegate;
}
@property (nonatomic, retain) NSString *bar;
@property (nonatomic, assign) id <ADelegate> delegate;
- (void)someAction;
@end
Also, what does the line
id <A Delegate > delegate;
@property (nonatomic, assign) id <ADelegate> delegate;
help us achieve..
in case of informal protocol... if i don't give an implementation for a method and still call the delegate method... what would happen.?