I'm trying to implement a library, but the library comes with minimal documentation and I'm a little out of my depth. By looking at other code I've got this far
Documentation says
AppDelegate creates an object of JBLayer as a member variable
So I did this in AppDelegate.h
#import "JBLayer.h"
//@class JBLayer;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
JBLayer *aJBLayer;
}
@property (nonatomic, strong, readonly) JBLayer *aJBLayer;
this in AppDelegate.m
@implementation AppDelegate
@synthesize aJBLayer = _aJBLayer;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
AppDelegate* appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
// THIS IS WHERE I'm STUCK
[aJBLayer SetHandler:self.doSetHandler];
// This is what I have to include the lib for, this seems to be ok
[aJBLayer MainCall];
return YES;
}
-(id)doSetHandler
{
return WHAT???;
}
The documentation says
Set the handler the receive callback events by calling SetHandler. AppDelegate needs to pass self if AppDelegate wants to receive the call back events.
Looking in the JBLayer.h file I find:
-(void)SetHandler:(id<interfaceJBHandler>)aHandler;
I have to implement these interfaceJBHandler methods which are in interfaceJBHandler.h
@protocol interfaceJBHandler
-(void)OnJBSuccess:(NSString *)aToken;
-(void)OnJBError:(NSError *)aError;
-(void)OnJBResponse :(NSData *)aData :(JBType )aTypeOfData;
I got as far as working out it's something like
[aJBLayer SetHandler:];
But everything I've tried gives errors
[aJBLayer SetHandler:self];
[aJBLayer SetHandler:appDelegate];
This compiles
[aJBLayer SetHandler:self.doSetHandler];
But I'm missing something, somewhere I have to make a delegate but up till now I've only done delegates to pas messages between viewcontrollers.
How do I make the AppDelegate receive the call back events?