Note that there are some explanatory texts on larger screens.

plurals
  1. PO"'NSInvalidArgumentException', reason: '-[UIButton intValue]: unrecognized selector sent to instance" between initwithNibName: and viewDidLoad
    text
    copied!<p>I have a fairly simple app (my first non-trivial iOS app) which I've been working on for some time. I've gotten the app finished and working, but I decided earlier today to refactor it to better fit OO design principles (in the interest of simplicity I had put most of my application in to the main view controller; I went back to try to split it out in to a second class). Now, whenever I try to run my app, I get a crash with the following error before my main view loads:</p> <pre><code>IntervalPlayer[1374:907] -[UIButton intValue]: unrecognized selector sent to instance 0x1c5569d0 </code></pre> <p>By throwing print statements everywhere, I can tell that I get through initWithNibName:bundle: OK, but the app crashes before viewDidLoad is called. Clearly something in my code is trying to call intValue on a UIButton, but there's nothing in my code that would do that - I only use intValue once in the entire app, and I get the same error when I comment that line out. In fact, I've tried commenting out everything in initWithNibName:bundle: after the call to the superclass constructor, and I'm getting the same error at the same place. So in other words, as best I can tell, something in an empty constructor is causing intValue to be called on a UIButton before anything else in my app has a chance to run. I assume its something in the delegate or nib, but I've looked through both and I haven't seen anything out-of-the-ordinary. Has anyone out there ever run in to something like this?</p> <p>Forgive the lack of code snippets, I'm not sure what I would provide to illustrate this. Here's the empty constructor, with which the error is still occurring:</p> <pre><code>- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)aBundle { self = [super initWithNibName:(NSString *)nibName bundle:(NSBundle *)aBundle]; if (self) { } return self; } </code></pre> <p>If anyone can suggest any other code to add, I'll edit the question to do so.</p> <p>Thanks,</p> <p>Dan</p> <p>EDIT: Yes, I am using ARC. Also, to clarify, this is occurring in my main view controller and I haven't touched the delegate. </p> <p>EDIT 2: The crash is in my delegate; according to the debugger the problem line is [self.window makeKeyAndVisible]; Since I haven't touched the delegate, my guess would be the NIB is somehow invalid.</p> <p>FINAL EDIT: By deleting buttons until I found the one causing the crash, then hooking it back up to everything it was hooked up to in the view controller, I found that it was crashing when the button was connected to a UIButton outlet, and not crashing when it wasn't. I removed the outlet, re-made it, and now it works. So I have no clue what happened, but somehow I fixed it. Many thanks to everyone who made suggestions!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload