In the example where class A calls class B to perform an action and then return something we would do this:
Class B's .h, this goes above the @interface
@protocol CLASSBNAMEDelegate <NSObject>
- (void) YOURMETHOD:(id) returnValue
@end
Then under the @interface
we add a delegate property:
@property (nonatomic, weak) id < CLASSBNAMEDelegate > delegate;
In class b .m where you want to send a message back to Class A you would:
if ([self.delegate respondsToSelector:@selector(YOURMETHOD:)]) {
[self.delegate YOURMETHOD:value];
}
In Class A, where you use Class B be sure to set the delegate like so:
ClassB *b = [Class B etc....];
[b setDelegate:self];
IN Class A Header make sure you:
@interface CLASSA : NSObject <CLASSBNAMEDelegate>
Then you would need to respond to the selector:
- (void) YOURMETHOD:(id) value{}
Hope this helps...