Bellow is the code i am calling when i press a button. The button will call the method bellow. But i get a "unrecognized selector sent to instance" error. What am i doing wrong? The objects have been declared in another method before this one is called. I have also tried hiding the buttons but they also crash. Someone please help.
-(void) clearControlPannel{
[buttCheck removeFromSuperview];
[buttBet removeFromSuperview];
[buttCall removeFromSuperview];
[buttRaise removeFromSuperview];
[buttFold removeFromSuperview];
[betLabel removeFromSuperview];
[betSlider removeFromSuperview];
}
The crash is:
Thread 1: EXC_BAD_ACCESS" on the [buttCheck removeFromSuper]; line
-[__NSCFDictionary removeFromSuperview]: unrecognized selector sent to instance 0x686b020 2012-06-24 19:08:12.175
HeadsUp[59630:f803] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary removeFromSuperview]: unrecognized selector sent to instance 0x686b020'
unrecognized selector sent to instance
error is due to the fact that the runtime is not able to find the method that will respond to that specific action. In other words, it's not able to map the name of your method (the selector) with its implementation.
So, if you have a method that accept no parameter like yours
- (void) clearControlPannel {...}
the selector will be only clearControlPannel.
Otherwise, if you have specified a parameter for that method (e.g. like the sender, the UIButton in this case) like
- (void) clearControlPannel:(id)sender {...}
the selector would be clearControlPannel:. Pay attention to :.
If you provide more details we could help you.
EDIT
Just for pointing you in the right direction.
If you have used – addTarget:action:forControlEvents: on a UIButton instance you have to check two things.
First, did you set up the target correctly? The target is the object to which the action will be redirected.
Second, did you set up the right selector for that action?
Here an example:
[myButton addTarget:self action#selector(mySelector:) ...];
where
- (void)mySelector:(id)sender {...}
If the class where you have implemented that button will also respond to that action use self, otherwise you need to inject some other instance that will respond for that action.
Check wheather you are releasing the button which you are pressing.
Related
Ok so as far as i can tell I'm getting the error when I'm calling a setter designed to fit the view into it's correct box.
_parrentViewFrame = parrentViewFrame;
self.containerView.frame = _parrentViewFrame;
self.containerView.bounds = _parrentViewFrame;
[self.containerView layoutIfNeeded];
on the layoutIfNeeded i get this error
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0xb000000000000343'
Now I've got similar code all over the app and it works just fine. I've put a symbolic break point at -[NSObject(NSObject) doesNotRecognizeSelector:]. but this doesn't really help. I still can't tell which object it's trying call length on. containerView is a simple UIView. The instance is always 0xb000000000000343, not sure if thats significant but it seems like it would be. How can I debug this problem?
One of two things might be going on:
As rmaddy pointed out, you may have assigned an NSNumber to a property that is not NSNumber. NSString seems like a likely candidate or an object that conforms to UILayoutSupport.
You might be overreleasing an object and an NSNumber is taking the place of that pointer, hence the bad selector call. If that is the case, you can turn on NSZombies, which will help you catch that overreleased object. Enable NSZombies in your scheme settings under Diagnostics.
I'm facing a problem while calling a method and I don't know how figure it out.
Basically, during the main menu, I want to call a SKNode showing a tutorial part. The code is the following:
- (void)didMoveToView:(SKView *)view
{
...
if ([[GameData sharedData] openingTutorial]) { // Checks if the menu needs the tutorial
[_tutorialObj performSelector:#selector(runTutorialWithStep:)
withObject:[NSNumber numberWithInt:8]
afterDelay:3.0
];
}
}
When the method didMoveToView: is called (even before waiting the 3 seconds for the runTutorialWithStep:), I got this error:
[UITextSelectionView name]: unrecognized selector sent to instance 0x1576e6c0
2014-10-14 11:01:19.430 [406:130379] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITextSelectionView name]: unrecognized selector sent to instance 0x1576e6c0'
The odd thing is that in the previous class I use the same tutorial's action in the didMoveToView: and it's working right. But...
Thing is getting more strange here!!!
If I use an intermediary method for this calls:
- (void)didMoveToView:(SKView *)view
{
...
[self performSelector:#selector(intermediaryMethod)
withObject:nil
afterDelay:3.0
];
}
- (void)intermediaryMethod
{
[_tutorialObj performSelector:#selector(runTutorialWithStep:)
withObject:[NSNumber numberWithInt:8]
afterDelay:0.0
];
}
Everything works without issues. I don't want to avoid the problem but solve this. Any advices?
The error says it all. You try to send a 'name' message to object that doesn't implement it (UITextSelectionView). Since your second take works the cause is either in
[[GameData sharedData] openingTutorial]
method or before this call. Search for objects calling 'name' and check if it's the UITextSelectionView in question.
That or maybe you have weak reference to general view object and during those three seconds before calling runTutorialWithStep you reassign it to object that implements 'name' message.
Ok, I solved the problem.
I added a breakpoint for every exception and I realized that the issues was due to an other class (the only one with UITextView).
Basically I removed the text field from its parent ([self removeFromParent]) by my own once I did not need it anymore.
I suppose the error was fired during the deallocation 'cause the program can't find the UITextView. I managed to remove this statement and everything works right.
Actually I still have doubts because I don't understand why this exception is throw only if I call the [_tutorialObj runTutorialWithStep:] method.
I found the way to fix it.
UITextView *textView = .....
textView.selectable = NO;
What I'm trying to perform
A programmatic unwind from Screen C back to Screen A (normally A->B->C)
What I've done
I've created the function - (IBAction)unwindToScreenA:(UIStoryboardSegue *)unwindSegue {
in Screen A's .m and its definition in .h file.
I've created an manual unwind in Screen C by CTRL-Dragging from Owner Icon to Escape Icon (unwind segue exists, but not tied to any button)
I've given the unwind a name, and then in the code I perform [self performSegueWithIdentifier:#"unwindFromCtoA" sender:self];
In other words, I think I've strictly done what's needed for this task. I did have it working before, but something else I changed must have broken it, and I can't trace the error.
The error I have
2014-02-06 13:28:28.899 PrototypeApp2[2885:60b] -[DMSScreenCViewController tag]: unrecognized selector sent to instance 0x14e7ff60
2014-02-06 13:28:28.902 PrototypeApp2[2885:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[DMSScreenCViewController tag]: unrecognized selector sent to instance 0x14e7ff60'
*** First throw call stack:
(0x2ddf7f4b 0x382386af 0x2ddfb8e7 0x2ddfa1cb 0x2dd494d8 0xc966d 0x30ae6d63 0xca34f 0x30782dcd 0x30782c15 0x306878bb
0x3073af7b 0x305eafb9 0x305631f3 0x2ddc31cd 0x2ddc0b71 0x2ddc0eb3 0x2dd2bc27 0x2dd2ba0b 0x32a52283 0x305cf049 0xc80a5 0x38740ab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
UPDATE
Changing
[self performSegueWithIdentifier:#"unwindFromCtoA" sender:self];
to
[self performSegueWithIdentifier:#"unwindFromCtoA" sender:Nil];
fixed it. Any ideas why?
The issue happened when you try to call tag property on your DMSScreenCViewController object.
This is a UIViewController subclass and there is no tag property so you cannot call it.
Maybe you try to call tag on your destination or source view controller in your segue method which is reference to DMSScreenCViewController object.
DMSScreenCViewController Check that this is the expected class as I suspect it's not.
You may have to update a storyboard
I'm getting an "unrecognized selector" error that is confusing me.
I know that I can "po" the pointer in LLDB to find out about the receiver. But is there a way to deduce which object is sending this message?
Thanks!
The command bt in the debugger will show you a backtrace (stacktrace), which should give you the class that initiated the message somewhere in that output.
Backtrace doesn't always help if you're dealing with multiple threads - you end up with the backtrace of the exception handler on the main thread which isn't necessarily the one that cause the error.
However, since you know that the particular selector doesn't exist for a particular class, you can cheat a little by using a category to add the selector to the class, then just stick a breakpoint on it.
For example, for this error:
-[__NSCFDictionary isEqualToString:]: unrecognized selector sent to instance 0x10004fb0
we know that something's trying to call "NSDictionary" with "isEqualToString". So, add this at the end of any file you like, outside any other "#implementation" blocks:
#implementation NSDictionary(debug)
- (BOOL)isEqualToString:(NSString*)theString {
return FALSE;
}
#end
Stick a breakpoint on this, re-run your code and you will get a genuine stack trace. Don't forget to remove the category once you've found the error!
I'm trying to call this method from a music-rendering function that is run in a different thread. The method is inside InstrumentGridViewController.
- (IBAction)stopPlayback:(id)sender{
[self stopToneUnit];
}
This is how I'm calling the method:
dispatch_async(dispatch_get_main_queue(), ^{ [InstrumentGridViewController stopPlayback: nil]; } );
But I'm getting this warning:
Class method `+stopPlayback` not found (return type defaults to `id`)
And when I try to run:
erminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[InstrumentGridViewController stopPlayback:]: unrecognized selector sent to class 0x13e50'
I'm sure the method is there so I really don't see why this is happening.
EDIT: H2CO3 said I should call the stopPlayback method on the currently running instance. Any ideas how I could do that?
Because the method is implemented as an instance method and not as a class method. You must call it on an object of class InstrumentGridViewController, and not on the class itself.