繁体   English   中英

未调用Dropbox委托方法

[英]Dropbox Delegate methods not being called

我的Dropbox API有问题。 我正在开发由另一个开发人员启动的大型应用程序。 现在,我要清理代码。 所有委托方法(loadedMetadata&Co.)都直接在视图中。 现在,我想将它们提取到自己的类中。 因此,我创建了一个DropboxService类,其中包含所有方法。 因此,我具有视图并从DropboxService调用方法loadMetadata。 该方法被调用并且可以正常工作。 但是从未调用Delegate方法loadedMetadata。

我做错了什么/必须做些什么才能使其正常工作?

Dropbox服务将DBRestClientDelegate作为“超类”(我不知道如何称呼它)

@interface DropboxService : CloudProviderService <DBRestClientDelegate> {
}

编辑:

该服务在AppDelegate中实例化,并且是一个变量:

- (DropboxService *)getDropboxService {
    if (self.dropboxService == nil) {
        self.dropboxService = [[DropboxService alloc] init];
    }
    return self.dropboxService;
}

来自德国的问候

亚历山大大帝

您还需要在初始化后设置委托

DBRestClient.delegate = self;

从这个界面

@interface DBRestClient : NSObject { ... id<DBRestClientDelegate> delegate;

这头犯规说DropboxService是一个子类的DBRestClientDelegate

它说, DropboxService符合的协议DBRestClientDelegate

Dropbox示例项目解释了所有这一切,但是您要查找在何处设置DBRestClient并确保将DropboxService作为该实例的委托。

这就是我的代码中符合DBRestClientDelegate

- (DBRestClient*)restClient {
    if (restClient == nil) {
        restClient = [((DBRestClient *)[DBRestClient alloc]) initWithSession:[DBSession sharedSession]];
        restClient.delegate = self;
    }
    return restClient;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM