[UILabel setAnswerText:]: unrecognized selector sent to instance 0x4916830' - objective-c

so i am getting an uncaught exception and im not sure why. this is the error i get:
2010-08-22 10:39:25.080 MayanGlyphs[10903:207] * -[UILabel setAnswerText:]: unrecognized selector sent to instance 0x4916830
2010-08-22 10:39:25.081 MayanGlyphs[10903:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UILabel setAnswerText:]: unrecognized selector sent to instance 0x4916830'
also i am getting a warning that UILabel may not respond to setAnswerText (answerText is the name of the label) even though i have created the outlet, connected it in IB, and synthesized it.
does anyone know why this might be happening?

answerText is the name of the label? then what are you trying to do?
If you want to access the answerText object (that being an instance of UILabel) you need to use self.answerText not [UILabel setAnswerText];
If you want to change the text in the label use:
answerText.text = #"Hello, this is my text";
or similar.

You need to do [setAnswerText setText:#"my text"]; What you are doing now is wrong. The reason you get that exception is that UILabel does not have a class method called setAnswerText:.

Related

Stupid crash when setting collection cell frame

It might be something stupid and i am doing this for years, but i just cant figure this one out .
In my collection view cell class i have this :
- (void)layoutSubviews
{
self.title.frame=CGRectMake(50, 50, 100, 100);
}
the cells are ok only if i remove this line of the frame settings, if not, i get :
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString setFrame:]: unrecognized selector sent to instance 0x7fdcbbd0afb0'
everything is set, and i didn't miss a thing, i already done that many times.
What is this ??
EDIT:
#property(nonatomic,strong) UILabel *title;
Oh no... thanks to the help of the good people here, i found out that i do this
cell.title=[dic objectForKey:#"title"];
instead of this
cell.title.text=[dic objectForKey:#"title"];
so it turned to a string ! (??)

How to track down error "unrecognized selector sent to instance"

I am getting the following error:
-[__NSCFBoolean isEqualToString:]: unrecognized selector sent to instance 0x56bb95c
Is it possible to track down what's the variable responsible of this error? The stack call is not helping me in this scenario.
You have a BOOL type while you are considering it as NSString and trying to compare with some other string by isEqualToString:
[__NSCFBoolean isEqualToString:]
....^^^^^^^^^

Difficulty implementing delegate methods in an objective-c project

I have a table view which I am using as a form.
The first cell has an editable text field. The second cell, when clicked, loads a semi modal date picker. I used this: http://reednj.tumblr.com/post/1346445326/ios-semi-modal-date-picker-for-iphone
Anyway, I've defined my datepicker and set its delegate inside the tableviewcontroller like so:
TDDatePickerController* datePickerView = [[TDDatePickerController alloc]
initWithNibName:#"TDDatePickerController"
bundle:nil];
[datePickerView setDelegate:self];
[self presentSemiModalViewController:datePickerView];
Now the methods to handle the button clicks are defined as
-(void)datePickerSetDate:(TDDatePickerController*)viewController;
-(void)datePickerClearDate:(TDDatePickerController*)viewController;
-(void)datePickerCancel:(TDDatePickerController*)viewController;
So when the cancel button is pressed I would like the semi-modal date picker to be dismissed, So I've got:
-(void)datePickerCancel:(TDDatePickerController*)viewController{
[self dismissSemiModalViewController:viewController];
}
But this makes the app crash with the error
-[__NSCFType cancelDateEdit:]: unrecognized selector sent to instance 0xe738c00
2012-09-18 10:23:47.254 JRPBaseCamp[7612:f803] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType cancelDateEdit:]: unrecognized selector sent to instance 0xe738c00'
So I looked up the cancelDateEdit method in TDDatePickerController:
-(IBAction)cancelDateEdit:(id)sender {
if([self.delegate respondsToSelector:#selector(datePickerCancel:)]) {
[self.delegate datePickerCancel:self];
}
}
What am I doing wrong? It must be something obvious that I'm overlooking. Any help is much appreciated, I'm fairly new to iOS and the whole concept of delegates is really confusing me.
Thanks!
The unrecognized selector sent means nothing is responding to cancelDateEdit: selector. You can use the debugger to search what kind of object is 0xe738c00 and then look for the appropriate selector there.

[__NSCFType searchKeyword:]: unrecognized selector sent to instance 0x6d8eb80

The following code is to add a subview to current view from storyboard:
EventSearchViewController* view1 = [self.storyboard instantiateViewControllerWithIdentifier:#"searchView"];
[view1 setBookingSystem:system];
[self.view addSubview:view1.view];
In the view "view1", there is a textField. The following is a IBAction to the textField and the event is "Did end on exit".
-(IBAction)searchKeyword:(id *)sender
{
NSLog(#"searchKeyword");
}
The following is the error message.
2012-05-26 20:26:47.369 OnlineBooking[6607:f803] -[__NSCFType searchKeyword:]: unrecognized selector sent to instance 0x6d8eb80
2012-05-26 20:26:47.369 OnlineBooking[6607:f803] * WebKit discarded an uncaught exception in the webView:shouldInsertText:replacingDOMRange:givenAction: delegate: -[__NSCFType searchKeyword:]: unrecognized selector sent to instance 0x6d8eb80
You need to retain your EventSearchViewController, or keep a strong reference to it if you're using ARC. If you assign it to view1 as a local variable, it's not going to be around any more when searchKeyword: gets called. (The error shows that its memory has been released and re-used for a different type of object.)
For me the problem was that I never called
- (void)removeTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents
before I called
- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents
again.

Array not retaining properly?

I get the following error when running my App:
2011-09-02 15:38:44.157 TheApp[9973:207] -[NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x4b28990
2011-09-02 15:38:44.160 TheApp[9973:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x4b28990'
And Xcode marks the line in this function in green:
- (void)oneCheckAndSetStrokes {
playerOneScoreNum.text = [playerOneScore objectAtIndex:(11)]; }
Therefore I'm guessing something is messed up with the Array. After som research I came across a lot of posts like this one: NSMutableArray : unrecognized selector sent to instance which seems to inticate that the error occurs when the Array is not being retain properly (hence my title).
So I'm trying to retain the Array in the file in wich it is initiated (which by the way is not the same file as the code above. The Array is also defined in another file, Globals.h, and then imported), in the following way:
- (void)viewDidLoad {
[super viewDidLoad];
playerOneScore = [[NSMutableArray alloc] initWithCapacity:19];
[playerOneScore retain]; }
This would solve the problem according to the post refered to earlier, but in my case it does not. Has anyone encountered something similar? It seems like I'm missing something trivial here.
The error you got has nothing to do with retain, you got that error because at this line:
playerOneScoreNum.text = [playerOneScore objectAtIndex:(11)];
you are trying to set a string property using a number object! You have to use "stringValue", in this way:
playerOneScoreNum.text = [[playerOneScore objectAtIndex:11] stringValue];
ps: wrapping the index (11) with parenthesis is useless :P