开发者

How to use delegates in general (but also within Soundcloud).

I am a noob when it comes to delegates, but I'开发者_StackOverflow社区m sure this will be a piece of cake for more experienced coders such as yourselves.

I have my app delegate setup up like this:

@interface iPhoneTestAppAppDelegate : NSObject <UIApplicationDelegate, SCSoundCloudAPIAuthenticationDelegate> {
    UIWindow *window;
    iPhoneTestAppViewController *viewController;
    SCSoundCloudAPI *soundCloudAPIMaster;
}


- (SCSoundCloudAPI *)soundCloudAPIMaster;
{
    if (!soundCloudAPIMaster) {
        SCSoundCloudAPIConfiguration *scAPIConfig = [SCSoundCloudAPIConfiguration configurationForProductionWithConsumerKey:kTestAppConsumerKey
                                                                                                    consumerSecret:kTestAppConsumerSecret
                                                                                                                callbackURL:[NSURL URLWithString:kCallbackURL]];
        soundCloudAPIMaster = [[SCSoundCloudAPI alloc] initWithDelegate:nil authenticationDelegate:self apiConfiguration:scAPIConfig];
        // make shure to register the myapp url scheme to your app :) 
    }
    return soundCloudAPIMaster;
}

which contains a method that gets called back:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url;

Then I have my viewController set up with this in the .h file:

@interface iPhoneTestAppViewController : UIViewController <SCSoundCloudAPIDelegate> 

and then in viewController.m I have a method that pushes a webview. Basically what I'm trying to do is get the callback method from the delegate file to callback to a method in the viewController.m file. (I would like to close my webView when I receive the callback).

Any ideas? Have I presented enough information to decipher my problem? Is this solvable as a general delegate issue or is it more of an Soundcloud specific problem?

EDIT 1

Here was an attempt to fix my problem that didn't work:

How to use delegates in general (but also within Soundcloud).


You need to set the delegate of the SoundClound variable to self otherwise the variable cannot pickup who the delegate is.

initWithDelegate:self ....


just write this code in ViewDidload Event...

yourcontrolname.delegate = self;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜