views:

28

answers:

0

Hello I got a UIViewController implementing UINavigationControllerDelegate and when i try to add UIActionSheetDelegate , it gives exception "NSInvalidArgumentException"

Here is my code:

RootViewController.h

@interface RootViewController : UIViewController <UINavigationControllerDelegate,UIActionSheetDelegate> {

}
-(IBAction) openActionSheet:(id) sender;
@end

RootViewController.m

#import "RootViewController.h"
@implementation RootViewController

-(IBAction) openActionSheet:(id) sender
{
   UIActionSheet *myActionSheet = [[UIActionSheet alloc] initWithTitle:@"UIActionSheet <title>"
                                      delegate:self cancelButtonTitle:nil destructiveButtonTitle:@"OK" otherButtonTitles:nil];
        myActionSheet.actionSheetStyle = UIActionSheetStyleDefault;
        [myActionSheet showInView: self.view]; 
        [myActionSheet release];
}

- (void)actionSheet:(UIActionSheet *) actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
 // the user clicked one of the OK/Cancel buttons
 if (buttonIndex == 0)
 {
  NSLog(@"**********  ok  ***************");

 }
 else
 {
  //NSLog(@"cancel");
 }
}

Just don't worry about the button and its call , bcs its connected and am not showing it here because of simplicity

Exception occurs when ActionSheet is initialized at line:

UIActionSheet *myActionSheet = [[UIActionSheet alloc] initWithTitle:@"UIActionSheet <title>"
                                      delegate:self cancelButtonTitle:nil destructiveButtonTitle:@"OK" otherButtonTitles:nil];

Exception thrown is:

unrecognized selector sent to instance 0x591c680
2010-09-13 10:43:32.901 TTW[67738:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RootViewController openActionSheet:]: unrecognized selector sent to instance 0x591c680'

PLEASE HELP !!!..........