Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使AppDelegate从自定义库接收回调事件_Ios_Objective C_Static Libraries_Appdelegate - Fatal编程技术网

Ios 使AppDelegate从自定义库接收回调事件

Ios 使AppDelegate从自定义库接收回调事件,ios,objective-c,static-libraries,appdelegate,Ios,Objective C,Static Libraries,Appdelegate,我正在尝试实现一个库,但是这个库只有很少的文档,我有点不懂。通过查看其他代码,我已经了解到了这一点 文件说 AppDelegate将JBLayer的对象创建为成员变量 所以我在AppDelegate.h中做了这个 #import "JBLayer.h" //@class JBLayer; @interface AppDelegate : UIResponder <UIApplicationDelegate> { JBLayer *aJBLayer; } @property (

我正在尝试实现一个库,但是这个库只有很少的文档,我有点不懂。通过查看其他代码,我已经了解到了这一点

文件说 AppDelegate将JBLayer的对象创建为成员变量

所以我在AppDelegate.h中做了这个

#import "JBLayer.h"
//@class JBLayer;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
    JBLayer *aJBLayer;
}
@property (nonatomic, strong, readonly) JBLayer *aJBLayer;
文件上说 通过调用SetHandler设置接收回调事件的处理程序。如果AppDelegate希望接收回调事件,则AppDelegate需要传递self

查看JBLayer.h文件,我发现:

-(void)SetHandler:(id<interfaceJBHandler>)aHandler;
我已经了解到这是一种

[aJBLayer SetHandler:];
但我所做的一切都会出错

[aJBLayer SetHandler:self];
[aJBLayer SetHandler:appDelegate];
这就编译了

[aJBLayer SetHandler:self.doSetHandler];
但我遗漏了一些东西,我必须在某个地方进行委托,但到目前为止,我只对ViewController之间的pas消息进行了委托


如何使AppDelegate接收回调事件?

您需要传递一个实现
interfaceJBHandler
协议的对象。如果希望您的appDelegate成为对象,请在头文件中更改以下内容,使您的appDelegate符合协议:

@interface AppDelegate : UIResponder <UIApplicationDelegate, interfaceJBHandler>
并在应用程序代理的实现文件中实现3个必需的方法:

-(void)OnJBSuccess:(NSString *)aToken{
    //Do Something
}

-(void)OnJBError:(NSError *)aError{
    //Do Something
}

-(void)OnJBResponse :(NSData *)aData :(JBType )aTypeOfData{
    //Do Something
}

JBLayer来自哪个库?它是来自客户端的自定义库,由一组文件组成,包括以下三个文件:libJB.a、JBLayer.h、interfaceJBHandler.hObvious。当被告知时。谢谢
@interface AppDelegate : UIResponder <UIApplicationDelegate, interfaceJBHandler>
[aJBLayer SetHandler:self];
-(void)OnJBSuccess:(NSString *)aToken{
    //Do Something
}

-(void)OnJBError:(NSError *)aError{
    //Do Something
}

-(void)OnJBResponse :(NSData *)aData :(JBType )aTypeOfData{
    //Do Something
}