Reputation: 39
im getting the SIGABRT error each time i build. Im seeing the reason below:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key numberEntered.'
-(IBAction)numberEntered:(id)sender
{
NSNumber *day=[NSString stringWithFormat:@"@%", dayEntry];
NSLog(@"%@", day);
}
I assume its something to do with me trying to pass the wrong value to *day, but i cant see what the issue is (no errors in xCode).
Essentially all i want to do is to retrieve a Numerical value from a textfield and set it do a variable (day) so i can use it in a calculation. I have added the NSLog in order to ensure im acquiring the correct data from my textfield.
Thanks in advance!
Upvotes: 1
Views: 1479
Reputation: 27597
Make sure your custom class implementation implementing numberEntered:
(subclassed UIView
/ UIViewController
/ UITextFIeld
or whatnot) is actually selected within the InterfaceBuilder under Custom Class, Class.
For the sake of this example, I am assuming it is a UIViewController
based class and you call it MyViewController
. In that sense, you will need to enter that name under the mentioned IB when observing the "File's Owner".
For validating if this actually was your problem, you could add something to your viewDidLoad
method that prints something into the console. Before being able to do so, you would have to remove that custom method from the event (as that baby would trigger the exception). If that something does not appear when showing the view of that viewController, you know that you have the described issue.
See this:
Upvotes: 0
Reputation: 31061
Make sure, that you actually have registered the method named numberEntered:
(note the trailing colon) with IB. It's a method different from numberEntered
(without the trailing colon). The error might be caused by
numberEntered
(instead of numberEntered:
)This could be caused by a missing (or wrong) File's Owner resp. Custom Class defined in a .xib
file for your control (hinted at by Till) or a plain old typo (missing the trailing :
).
Upvotes: 0
Reputation: 34935
The other problem is your format string and the fact that you are assigning an NSString
to an NSNumber
.
NSNumber *day=[NSString stringWithFormat:@"@%", dayEntry];
Try to change it to:
NSString *day=[NSString stringWithFormat:@"%@", dayEntry];
Subtle difference, see if you can spot it.
Upvotes: 1
Reputation: 1624
try this out :
NSNumber *day = [NSNumber numberWithInt:[dayEntry intValue]];
Upvotes: 0