Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 4, 2013, 10:45 AM   #1
Senor Cuete
macrumors regular
 
Join Date: Nov 2011
Problem with XCode 4 .6

I upgraded from XCode 4.5 to XCode 4.6 two days ago. Now none of my class methods will work if they have more that one parameter. For example:

Code:
@interface  myClass : NSWindowController <NSTextFieldDelegate>
- (void) myMethodName: (int) x menu: (NSPopUpButton *) myMenu;
@end

@implementation
- (void) myMethodName: (int) x menu: (NSPopUpButton *) myMenu
{
}
@end
When I send my object a message such as:
Code:
[self myMethodName: (int) x menu: (NSPopUpButton *) myMenu];
It will cause an error: unrecognized selector sent to instance 0xnnnnnnnnn.

This builds correctly with no warnings and it worked in earlier versions of Xcode.

What's wrong?

I turned the Apple LLVM compiler 4.2 - warnings -Objective C

Multiple Definition Types for Selector
Strict Selector Matching and
Undeclared Selector

to yes and rebuilt the project. No warning during build but crash during execution.

Last edited by Senor Cuete; Feb 4, 2013 at 11:03 AM. Reason: More info
Senor Cuete is offline   0 Reply With Quote
Old Feb 4, 2013, 11:06 AM   #2
gnasher729
macrumors G5
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by Senor Cuete View Post
This builds correctly with no warnings and it worked in earlier versions of Xcode.

What's wrong?
There's a bug in your code.

First, remove the casts when you send the message. Casts will only serve to hide problems. Then turn on all the warnings in Xcode that you can turn on and fix any problems that Xcode tells you about.

I'd say "self" is not what you think it is. Which could easily happen because you cast an object of type X to type Y.

What about some simple debugging? Breakpoint on the line that crashes, and look at the contents of variables, including self.
gnasher729 is offline   0 Reply With Quote
Old Feb 4, 2013, 11:28 AM   #3
Senor Cuete
Thread Starter
macrumors regular
 
Join Date: Nov 2011
I don't have the casts in my code, I carelessly put them in my example.

I don't cast any object to the type of self or any of the variables such as the int or (NSPopUpButton *). The calls to [self selector] are in the implementation of the object. Breakpoints are set at offending call to [self selector]. self is a valid allocated object instance with a hex address. XCode finds no problems when building but crashes during execution. This worked with Older versions. XCode seems to be building the project with no problem but failing to recognize the selector at runtime. I'll look at the build settings. Maybe I have some setting like build for 10.8 set and I'm using 10.7. I'll check.

It probably doesn't matter but this project was written with Objective C 1 - no reference counting or ARC.
Senor Cuete is offline   0 Reply With Quote
Old Feb 4, 2013, 02:00 PM   #4
chown33
macrumors 603
 
Join Date: Aug 2009
Copy and paste the complete text of the actual error message. You've left out an important part of it, the part that identifies what the actual class of the object is.

Also post the exact actual code, rather than the hypotheticals myMethodName and myClass. We need to see exactly what the code is. Hypotheticals haven't been compiled.

If you can't post those right away, do it later when you have the actual code and error messages at hand. Accuracy is important.
chown33 is offline   2 Reply With Quote
Old Feb 4, 2013, 05:03 PM   #5
Senor Cuete
Thread Starter
macrumors regular
 
Join Date: Nov 2011
2013-02-04 14:52:04.431 myApp[5041:303] -[myClassName myMethodName:myInt:]: unrecognized selector sent to instance 0x102407b10
2013-02-04 14:52:04.432 myApp[5041:303] Exception detected while handling key input.

Then a whole list of errors.

All possible error messages turned on in project and target settings but build generates no errors.
Senor Cuete is offline   0 Reply With Quote
Old Feb 4, 2013, 07:31 PM   #6
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by Senor Cuete View Post
2013-02-04 14:52:04.431 myApp[5041:303] -[myClassName myMethodName:myInt:]: unrecognized selector sent to instance 0x102407b10
2013-02-04 14:52:04.432 myApp[5041:303] Exception detected while handling key input.

Then a whole list of errors.
Please post your actual code, at the point where the error is coming from. That is, at the point where myMethodName:myInt: is actually being messaged.

Your first post had this:
Code:
[self myMethodName: (int) x menu: (NSPopUpButton *) myMenu];
The method signature is myMethodName:menu: . This differs from what's in your error message above, which is myMethodName:myInt: .

Also, your class name in your first post is myClass, yet the class name in the error message is myClassName.

If those are the actual method and class names, then the problem should be clear: you don't have the method you seem to think you do. Why this might be so can only be guessed at without seeing your actual code. It may be an optional method in a protocol. Your code may be doing something unexpected. We don't know, because you have not yet posted your actual code, only a hypothetical. The hypothetical is clearly not the same as what's in the error message, because the methods are clearly different.

If those are not the actual method and class names, then please post the actual unaltered class name, method name, and the actual unaltered error message output.


When you say the build generates no errors, do you mean no errors or warnings? Because you may only be getting a warning.
chown33 is offline   0 Reply With Quote
Old Feb 4, 2013, 08:03 PM   #7
Senor Cuete
Thread Starter
macrumors regular
 
Join Date: Nov 2011
Quote:
Originally Posted by chown33 View Post
When you say the build generates no errors, do you mean no errors or warnings? Because you may only be getting a warning.
No errors or warnings, even with all warnings turned on
Senor Cuete is offline   0 Reply With Quote
Old Feb 11, 2013, 10:15 AM   #8
Senor Cuete
Thread Starter
macrumors regular
 
Join Date: Nov 2011
Solved

First I changed the names of the parameters so there was no name collision with variables in some .h files for some .c files in the project. I don't think that this was the problem.

Then I carefully copied the parameters, etc. to the method implementations so that the parameters, etc. are exactly the same. This solved the problem. I think that there was a typo in the name of one or more parameter or parameter name. It's surprising that XCode wouldn't catch this and at least give me a warning when I built the project.
Senor Cuete is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
XCode 5 DP and Java Problem aquethys Mac Programming 0 Aug 28, 2013 10:59 PM
Xcode OpenGL Ram Problem jmfel1926 Mac Programming 5 Aug 21, 2013 07:06 PM
Moving from xcode 3.2 to xcode 4.5.2 compilation error for 'abs' macro in stdlib.h hrishidev Mac Programming 7 Jun 2, 2013 11:36 AM
After updating XCode, output terminal problem iMacFarlane Mac Programming 9 Oct 4, 2012 12:29 AM
Xcode problem JamesP. Mac Applications and Mac App Store 0 Jul 4, 2012 11:41 AM

Forum Jump

All times are GMT -5. The time now is 06:49 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC