+[NSInvocation invocationWithMethodSignature:]: method signature argument cannot be nil (Cocos2d) - iphone

I'm having this issue with cocos2d. Hopefully someone else has seen this before. The error message (in the title):
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '+[NSInvocation
invocationWithMethodSignature:]: method signature argument cannot be
nil
keeps coming up when I'm trying to draw a scene. To get to it, you click a button on the main menu and it brings you directly to it. I've stepped into it and it crashes on the line where I'm trying to add some buttons:
CCMenuItem *menuItem1 = [CCMenuItemImage
itemFromNormalImage:#"menubtn-normal.png"
selectedImage:#"menubtn-pressed.png"
target:self
selector:#selector(displayMatchMaker:)];
When I use the method where "target: self selector:#selector(displayMatchMaker:)]" is not there, it works fine and draws the button. The displayMatchMaker: method DOES exist, in this same implementation. I'm beginning to lose my mind here! Hopefully someone can help me!
Here's the method implementation:
- (void)displayMatchMaker:(id)sender{
...
}

As it turns out, the code was in the wrong spot. It was crashing because it technically couldn't see the method, even though it was in the same implementation. Once I moved the code over to a new location, it worked fine.

If I remember correctly the selector should be without colon:
#selector(displayMatchMaker)
-(void) displayMatchMaker { }

Related

xib overlay in storyboard causing uncaught exception

My main app is using Storyboard's for laying all my views out. Next... I've also got a xib file that holds a few buttons that I'd like to apply in a fancy sort of overlay. This is also working great using a technique I found here: http://www.stackoverflow.com/a/12574190/949538
The Files Owner is hooked up to the main view controller. And from a button on my main view, I can pop open this xib nicely.
The problem comes from trying to attach an IBAction to anything I put on this xib. All of i have no warnings, no build errors, everything looks fine. Until I pop open the xib/view, and hit one of my buttons, then I get this:
2012-11-19 15:44:48.685 Frolfer[89367:c07] -[UIViewController closeStartPanel:]: unrecognized selector sent to instance 0x8352e90
2012-11-19 15:44:48.686 Frolfer[89367:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController closeStartPanel:]: unrecognized selector sent to instance 0x8352e90'
MainViewController.m
-(IBAction)closeStartPanel:(id)sender {
NSLog(#"close start panel");
}
It's got to be something just so basic that I'm forgetting / missing.
Any thoughts?
P.S.
There literally is not much code written yet, but if you'd like to see anything more just let me know. I'm not sure exactly what it is that you'd like to see...
Thanks in advance!!
- drew
Is there closeStartPanel: selector defined for that UIButton ? Can you post code for that? the exception clearly states that it is not able to find closeStartPanel selector for that UIButton in UIViewController...
I figured it out!
Not sure why I didn't try this before, but it works great now.
Usually when I'm in the Storyboard, I'd drag 'Touch Up Inside' handle over on top of my button to see the available IBActions's that I had created in my header. With the xib file, this wasn't happening at all. So as noted previously, I changed class of the Files Owner on my xib to my MainViewController.
After that, all my defined IBActions were appearing as I had expected them to when dragging 'Touch Up Inside' over to the button on screen in IB.
That's where the crashes started happening though.
This morning, I removed all associations to MainViewController on my xib file, and by accident, had drug the 'Touch Up Inside' handle over to First Responder. I guess I don't play with First Responder much... but to my surprise, all my IBActions were listed in there. For some reason, I thought I wouldn't see them.
After a clean and compile... boom, they worked! I guess the only downside (if you want to call it that), is that in the code view, it doesn't give an indication that your defined IBAction is hooked up to a button in the IB with the filled in gray dot like my other buttons that are directly on the storyboard do.
Oh well, seems to be working the way I had hoped (for now), so I'm going to just roll with it.
:-)
Have a great Thanksgiving weekend.
- Drew

controllerview stopAnimating unrecognized selector sent to instance

I am getting this error when I load a new tableview onto my navigational stack.
All of the data displays in the table that I am parsing onto it however once that has finished the app stops working and I get this error.
Just wondering if anyone knows what the problem might be? or how I might be able to debug it?
If you need more code let me know I just don't know what to provide because I'm not sure what the error refers too.
-[VehicleResultViewController stopAnimating]: unrecognized selector sent to instance 0x6a2a680
You need to post more code.
In general, an unrecognized selector error occurs when you try to invoke a method on a class that does not have the method implemented.
Is VehicleResultViewController a UITableViewController/UIViewController? Have you added the stopAnimating method? UIViewController and it's subclass, UITableViewController do not have a stopAnimating method in their default implementation.
If it's a UITableViewController or a UIViewController and you haven't added a stopAnimating method, then you're calling a method that VehicleResultViewController does not have hence the crash.
It's really hard to answer your question more accurately until you:
Post code for where you call the method
Post the header file for VehicleResultViewController so we can see what kind of class is it (or you could just tell us).
It could also be (and more probably is) that you have a UIActivityIndicatorView in your code which you want to stop spinning. In that case, are you sure it's named 'vehicleResultViewController'? Whatever your UIActivityIndicatorView is named, try calling:
[whatever_your_activity_indicator_view_is_named stopAnimating];

Crash (SIGABRT) while adding a view. (WebView)

I am having a crash (triggered by an exception) while adding a WebView. I haven't figured out why. And yes I have browsed the web because this is a very common problem though with no success, I found an answer saying that I should implement the DSYM to track the stack correctly, because looking at all those addresses is just meaningless (and I agree), the thing is I have no idea on how to do this. I found this: save dsym files. But I didn't figure out how to integrate it into my project, besides it looks dangerous. And yes I have NSZombie enabled too, but to no avail.
Anyway now to the point of my question. I have a button that triggers an event, the event changes a string (the URL) according to the button pressed. Then this IBAction calls on the delegate, and the delegate makes a transition to a view that has a UIWebView that will open with the URL edited by the IBAction. So I have the following code:
This is the Delegate method:
WebViewController *awebViewController = [[WebViewController alloc]
initWithNibName:#"WebView" bundle:nil];
[self setWebViewController:awebViewController];
[awebViewController release];
self.webViewController.finalURL = [NSMutableString stringWithFormat:#"%#", linkString];
[viewController.view removeFromSuperview];
// HERE happens the crash, found out using breakpoints
[self.window addSubview:[webViewController view]];
[UIView commitAnimations];
[viewController release];
viewController = nil;
This is the exact crash message:
-[WebView initWithCoder:]: unrecognized selector sent to instance 0x5718320
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '[WebView initWithCoder:]: unrecognized selector sent to instance 0x5718320'
I have the theory that it tries to make the transition but that there is no actual view to add. Though that is a wild guess. Exceptions are usually called by those kinds of things but in this case I don't see what is happening.
Thank you for your help, and forgive me if it is too dumb a question.
a guess from my side:
Do you have a view in your nib that should be a UIWebView but you changed the Class of that view to WebView?
You should first check this in interface builder.
This exception is exactly what happens if you change the Class of a view element to a class that isn't available.
The exact error is that some instance of a class called WebView (not UIWebView) at memory address 0x5718320 is being sent the message -initWithCoder:, which it doesn’t recognize. That message is called when loading views created with Interface Builder; check your nibs for a view that you’ve changed to a custom WebView class.
I had same problem, and renamed class WebView into WebViewCustom by XCode refractor/Rename feature, cleaned up project and now it works fine.

application crashes on calling popViewController : error: alertView:didDismissWithButtonIndex:

A description of the problem is as follows:
I have a view, say, view A. To enter certain data, I have an alert,with a text field inside it, which pops up. Once the user enters data into the text field, i have an alertView:didDismissWithButtonIndex: function as follows :
- (void)alertView:(UIAlertView *)alertView:didDismissWithButtonIndex:(NSInteger)buttonIndex {
[ amountEntered resignFirstResponder]; //dismiss keyboard
if (buttonIndex == 1) { //OK clicked, do something
if(lblShowTypedText.text)
data.investmentAmount = lblShowTypedText.text ;
[myTable reloadData];
}
}
Then I have a submit button on my View A, which when clicked pops back to the previous view. Here is where my app crashes. There is no message in the console, however after many runs, I got one message like this:
* -[NSCFType alertView:didDismissWithButtonIndex:]: unrecognized selector sent to instance 0x3c4dce0
2010-06-24 15:33:22.970 BankingAppln[2895:207] CoreAnimation: ignoring exception: * -[NSCFType alertView:didDismissWithButtonIndex:]: unrecognized selector sent to instance 0x3c4dce0
Thus i have narrowed down the problem to the alertView:didDismissWithButtonIndex: function. If I do not call the alert, but directly pop back to the previous view, everything is fine.
I must be doing something wrong in my alertView:didDismissWithButtonIndex: function.
Pls help!!
A few things to check:
You set the delegate of the AlertView to the right class (View A)?
Your class (View A) implements the UIAlertViewDelegate protocol.
Probably not, but you never know: You're classname is not equal to a name in apple's private api (don't laugh, happened to me a week ago, costed me 2 hours to figure out)?
EDIT:
Another thing to check:
Your delegate method has the right return type (I think it's "void" in that case)?
Do you really have this method, alertView:didDismissWithButtonIndex:, in your class? and post the code when you call it as well
You need to post where you call the method..but from the error message you gave, the problem is you are calling your method incorrectly.
if it is a method you defined yourself with the implementation above use
[self alertView:myAlertView didDismissWithButtonIndex:myIndex];
also, in your declaration, you have a semicolon after the parameter alertView and you just need a space.
I faced a similar problem and it turns out that with Automatic Reference Counting in place, I needed to keep a reference to the popup around as a property so that it would not be reference collected. That much was fine but I got overzealous and started doing stuff like popup = nil; explicitly and that got me into trouble because some of the delegate methods for the popup were called after I had nil'ed out the reference that I was holding onto and now this popup was not around anymore and the framework crashed due to this little fact.
[__NSCFString alertView:didDismissWithButtonIndex:]: unrecognized selector sent to instance 0x9117c0
So I decided to simply keep allocating a new popup when it was needed and not explicitly nil'ing out the older references. This fixed the issue for me.

How do I debug an 'unrecognized selector sent to instance' problem?

I have the following code in a view controller that (in all other respects) seems to be working fine:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
ProblemViewController *problemViewController = [[ProblemViewController alloc] initWithNibName:#"ProblemViewController" bundle:nil];
problemViewController.problem = (Problem*)[self.problems objectAtIndex:indexPath.row];
[self.navigationController pushViewController:problemViewController];
[problemViewController release];
}
When I run through this function, however, I am getting the following error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[ProblemViewController initWithNibName:bundle:]: unrecognized selector sent to instance 0x57ca80'
I'm at a loss as to what could be causing it, so my question is: How should I best go about debugging this problem? Is there anything obvious I should be checking?
Check the base class for ProblemViewController. I'm betting you're not inheriting from UIViewController, which includes the initWithNibName:bundle: method.
There are a bunch of answers to this question that all basically say the same, correct, thing: Somehow, the method you're trying to call doesn't actually exist.
BUT, if you're beating your head against the wall (like I was for an hour today), make sure you try cleaning your project in xcode first. Sometimes, I don't know why, xcode can get into a bad state and will not properly compile your project into the simulator. It will tell you the build is successful, but when deployed to the simulator, you start seeing runtime errors as though only half your changes were picked up. So yeah, that happens.
You likely don't have that method implemented in your ProblemViewController. Unrecognized selector is, as far as I know, just that there's no method defined in this class's interface that has that signature.
Try declaring it in your interface like this:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil;
I thought I better post something on this issue. I fought it for a couple of days. There are a lot of blogs on this, but none of them solved the problem. Some suggested that it had to do with pushViewController needing to specify animated:YES. It worked for some, but that didn't work for the issue I was having. I was using a button to access another view rather than selecting a row from a table view, but was getting the same unrecognized selector error. I was also using a navigation controller so I thought it had something to do with that, but it didn't. Finally, I decided to comment out lines of code till the message went away. After commenting out the method that was causing the problem, the error message still came up in the console. That is when I realized the problem was not with my source code. One site recommended performing a clean and rebuild. I tried all that and still the problem persisted. I then looked at my XIB file using Interface Builder to see what methods(Received Actions) displayed on the File Owner. There was the problem. Not only did the offending method show up once on the File Owner, but it displayed twice. Don't know how to display the image of this here. Anyway, I deleted the methods (Received Actions) with the same name that appeared on the File Owner. I performed a clean and rebuild to see if the error went away and it did. I then uncommented the source I thought was bad and built the project again and the call to the new view was successful.
I will share my experience with the same error code. It is possible to make a mistake my assigning a the object to the wrong target. For example, if you have some UILabel property and you have accidentally assigned the string constant directly to self.myUILabelProperty = #"ups" then you property will become object of type NSString instead of being UILabel, so you loose all the UILabel methods. After that mistake, if you try to use UIlabel methods on the property in code you will get this error message.