0
votes

I am having an issue in iphone when i want to use a custom button in the keypad(text field filler) of my application page. i have embedded a button named dot in the keypad and it is appearing fine but when i click it, it is supposed to go to an action which i defined. but it crashes.

- (void)sendDecimal:(id)sender {
    // Post a Notification that the Decimal Key was Pressed.
    [[NSNotificationCenter defaultCenter] postNotificationName:@"DecimalPressed" object:nil];   
}

it runs till the application tries to send notification to i dont know may be the routine or function or method.

Can somebody help me in this regards.

thanks

EDIT

Here is the error message:

-[UITableView addDecimal:]: unrecognized selector sent to instance 0x4051e00 
2010-03-26 16:08:42.272 app[2855:20b]

Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '-[UITableView addDecimal:]: unrecognized selector sent to instance
0x4051e00' 

EDIT

i have defined the addDecimal selector, here is the code......

- (void)viewDidAppear:(BOOL)animated    {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:tableView selector:@selector(addDecimal:) name:@"DecimalPressed" object:nil];

Edit

Yes i have written this as [dot addTarget:self action:@selector(sendDecimal:) forControlEvents:UIControlEventTouchUpInside];

2
Can you copy and paste the error message from the Console? This would be immensely helpful. - Alex Reynolds
*** -[UITableView addDecimal:]: unrecognized selector sent to instance 0x4051e00 2010-03-26 16:08:42.272 app[2855:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UITableView addDecimal:]: unrecognized selector sent to instance 0x4051e00' - Filthy Knight

2 Answers

1
votes

have you written something like

[YourButtonButton addTarget:self action:@selector(addDecimal:) forControlEvents:UIControlEventTouchUpInside];

Then replace it with

[YourButtonButton addTarget:self action:@selector(sendDecimal:) forControlEvents:UIControlEventTouchUpInside];

from your comment i am guessint it's just spelling mistake or something

0
votes

Problem Solved Guys

Error

[[NSNotificationCenter defaultCenter] addObserver:tableView selector:@selector(addDecimal:) name:@"DecimalPressed" object:nil];

Resolve:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addDecimal:) name:@"DecimalPressed" object:nil];

Put addObserver to self rather than tableview