1

I am implementing a Protocol of my UIViewController Class. I need to perform methods of this Protocol in another class. But its not working.

Below is the code. Please help me out.

///This is my Header Class

#import <UIKit/UIKit.h>

@protocol PauseViewDelegate <NSObject>

- (IBAction)ResumeButtonPressed:(id)sender;
- (IBAction)MenuButtonPressed:(id)sender;
- (IBAction)RestartButtonPressed:(id)sender;

@end

@interface PauseViewController : UIViewController

@property (nonatomic, retain) id<PauseViewDelegate> pauseDelegate;

@end



////This is implementation class protocol Methods.

#import "PauseViewController.h"

@interface PauseViewController ()

@end

@implementation PauseViewController
@synthesize pauseDelegate;

- (IBAction)ResumeButtonPressed:(id)sender
{
    NSLog(@"resume delegate");
        [pauseDelegate ResumeButtonPressed:sender];

}
- (IBAction)RestartButtonPressed:(id)sender
{
    NSLog(@"Restart delegate");
    [self.view removeFromSuperview];
    [pauseDelegate RestartButtonPressed:sender];
}
- (IBAction)MenuButtonPressed:(id)sender
{
    NSLog(@"Menu delegate");
    [self.view removeFromSuperview];
    [pauseDelegate MenuButtonPressed:sender];
}

And i am using these methods in different view controller but its not working.

2
  • the implementation is good but how you use in your class ie how you call it in calling or implementing class? Can you put some code regarding that may you missing something there :)
    – The iOSDev
    Nov 15, 2012 at 11:37
  • - (IBAction)ResumeButtonPressed:(id)sender { NSLog(@"Resume Button In play Area"); levelTimer = [NSTimer scheduledTimerWithTimeInterval:BirthTime target:self selector:@selector(addSmiley) userInfo:nil repeats:YES]; [PauseButton setHidden:NO]; } - (IBAction)RestartButtonPressed:(id)sender { NSLog(@"Restart Button In play Area"); [audioPlayer stop]; } These are the Methods implemented in other class. Nov 17, 2012 at 7:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.