I have a problem with the Dropbox API. I'm working on big app, which was started by another developer. Now I'm going to clean the code. All the Delegate Methods (loadedMetadata & Co.) were directly in the view. Now I want to extract them into their own class. So I created a DropboxService class with all the methods in it. So I have the view and call the method loadMetadata from the DropboxService. The method is called and woking fine. But the Delegate method loadedMetadata is never called.
What did I do wrong / what do I have to change to get this working correctly?
The Dropbox Service has the DBRestClientDelegate as a "Superclass" (don't know how it i exactly called)
@interface DropboxService : CloudProviderService <DBRestClientDelegate> {
}
Edit:
The Service is instantiated in the AppDelegate and is a variable there:
- (DropboxService *)getDropboxService {
if (self.dropboxService == nil) {
self.dropboxService = [[DropboxService alloc] init];
}
return self.dropboxService;
}
Greetings from Germany
Alexander
You need to also set the delegate after init
DBRestClient.delegate = self;
from this interface
@interface DBRestClient : NSObject { ... id<DBRestClientDelegate> delegate;
That header doesnt say that DropboxService
is a sub-class of DBRestClientDelegate
it says that DropboxService
conforms to the protocol of DBRestClientDelegate
The Dropbox sample project explains all this, but you want to look for where you set up DBRestClient
and make sure DropboxService
is made the delegate of that instance.
This is what it looks like in my code which conforms to DBRestClientDelegate
- (DBRestClient*)restClient {
if (restClient == nil) {
restClient = [((DBRestClient *)[DBRestClient alloc]) initWithSession:[DBSession sharedSession]];
restClient.delegate = self;
}
return restClient;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.