我有一个对象incall
的类。我有一个方法设置它,另一个方法运行该对象的方法。已设置实例变量nil
这里是我的头文件:
@interface RCTPlivo : NSObject <PlivoEndpointDelegate, CXProviderDelegate>
@property (nonatomic) PlivoIncoming *incall;
@property (nonatomic) PlivoEndpoint *endpoint;
@end
这里是我的执行文件:
@implementation RCTPlivo
- (void)login {
endpoint = [[PlivoEndpoint alloc] init];
[endpoint login:plivoUser AndPassword:plivoPass];
endpoint.delegate = self;
}
- (void)triggerIncomingCall {
...
CXProvider *callkitProvider = [[CXProvider alloc] initWithConfiguration: configuration];
[callkitProvider setDelegate:self queue:nil];
...
[callkitProvider reportNewIncomingCallWithUUID:currentCall update:update completion:^(NSError * _Nullable error) {
if (error) {
NSLog(@"Error: %@", error);
}
}];
}
- (void)onIncomingCall:(PlivoIncoming *)incoming {
// setting
self.incall = incoming
}
- (void)provider:(CXProvider *)provider performAnswerCallAction:(CXAnswerCallAction *)action
{
// Here self.incall is null
[self.incall answer];
}
@end
当我登录perfromAnswerCall self.incall
委托它为空。当我登录onIncomingCall委托时,变量被设置。
我在这里错过了什么?
更新 添加了初始化委托和删除ivars的代码。
您正在将它设置为错误的实例。 – dasblinkenlight
那么我该如何做到这一点呢? @dasblinkenlight – Ismailp
你需要先展示你如何做不正确的方式。我的意思是,你调用setter的上下文,这个代表被调用的上下文。 – dasblinkenlight