1

XCode is driving me crazy (again). How do people use this?

-[UIViewController look_for_offer:]: unrecognized selector sent to instance 0x4e34220
2011-04-30 18:38:25.207 myApp[8261:40b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController look_for_offer:]: unrecognized selector sent to instance 0x4e34220'

Here's what I did. I made a button. I clicked on the button and went to the "connections" tab in the inspector. I dragged from the touch-down-event to the code and it automatically created an empty method and a method header. This is the method:

- (IBAction)look_for_offer:(id)sender {

}

Now remember, I didn't even write that. Interface Builder generated it for me. Yet when I build and click the button, I get the "unrecognized selector" error message.

It looks from the error message like he's trying to send the message look_for_offer to UIViewController. I don't know why he would do that. The method is in my view, which is a subclass of UIViewController:

@interface ClientSeekingView : UIViewController {

}

- (IBAction)look_for_offer:(id)sender;

I clearly dragged the action into that classes code, not into UIViewController. Why is he trying to send messages to UIViewController instead of my class?

What am I doing wrong? How do I please Xcode?

PS: I cleaned and rebuilt several times, doesn't help.

MrB

一二三
  • 21,059
  • 11
  • 65
  • 74
MrB
  • 2,155
  • 7
  • 27
  • 33
  • Possible duplicate of [How can I debug 'unrecognized selector sent to instance' error](https://stackoverflow.com/questions/25853947/how-can-i-debug-unrecognized-selector-sent-to-instance-error) – Cœur Jul 08 '19 at 05:53

1 Answers1

9

It looks like you didn't change the Interface Builder File's Owner object to your own class. IB has created an object of type UIViewController, not ClientSeekingView. The error message says that your selector is being sent to an object of class UIViewController.

To change the class, you would use the Identity Inspector. Identity Inspector Menu Item

Black Frog
  • 11,595
  • 1
  • 35
  • 66
odrm
  • 5,149
  • 1
  • 18
  • 13
  • How do I change the "File's Owner"? There's a cube called "File's Owner" in the sidebar, but I can't seem to enter my class anywhere. – MrB Apr 30 '11 at 17:05
  • @MrB, I added a screenshot of the menu item to change the class name. – Black Frog May 01 '11 at 12:14