views:

451

answers:

1

I creat a button and response click event,but get error:

-[NSCFDictionary numberButtonClick:]: unrecognized selector sent to instance 0x3d03ac0 2010-03-16 22:23:58.811 Money[8056:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSCFDictionary numberButtonClick:]: unrecognized selector sent to instance 0x3d03ac0'

this my code:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {

    UIButton *numberButton = [UIButton buttonWithType:UIButtonTypeCustom];        
    numberButton.frame = CGRectMake(10, 435, 46, 38);
    [numberButton setImage:[UIImage imageNamed:@"one.png"] forState:UIControlStateNormal];
    [numberButton addTarget:self action:@selector(numberButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview: numberButton]; 

}
return self;

}

-(IBAction)numberButtonClick:(id)sender{
NSLog(@"---");

}

Any help would be REALLY, REALLY appreciated...

Thanks,

Dy.

+3  A: 

It looks like you're not memory managing the view controller properly and it is being deallocated at some point - which causes the numberButtonClicked: method to be sent to another object that is now occupying the memory that the view controller was previously occupying...

Make sure you're properly retaining/releasing your view controller.

Jasarien
Thank you very much!
HelloWorld