views:

17

answers:

2

I found this in some example code I downloaded

#import "PreferencesViewController.h"
@class MetronomeView;

@interface MetronomeViewController : UIViewController <PreferencesViewControllerDelegate> {
    MetronomeView *metronomeView;
}

@property (nonatomic, assign) IBOutlet MetronomeView *metronomeView;
- (IBAction)showInfo;   

@end

I tried to find information on PreferencesViewControllerDelegate, but didn't find much. What is this delegate?

+1  A: 

This looks like a custom delegate created by whoever wrote the code you downloaded. It's not an Apple delegate, since it doesn't start with any of Apple's two-letter prefixes.

Ben Gottlieb
+2  A: 

It's a custom view controller delegate protocol that is created by Apple, for use in the Metronome sample project (and I imagine others). The protocol declaration can be found here, and how it's implemented can be seen here.

All it does is act as a delegate that monitors what happens to PreferencesViewController, the controller that manages the preferences view.

The protocol contains one method called preferencesViewControllerDidFinish:, which is implemented by MetronomeViewController like this. When the delegate receives a signal that the preferences view has been dismissed with the Done button, this is called to hide the view:

- (void)preferencesViewControllerDidFinish:(PreferencesViewController *)controller {

    [self dismissModalViewControllerAnimated:YES];

}

A similar delegate called FlipsideViewControllerDelegate can be found in the Xcode iOS project template for a Utility Application.

BoltClock