Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-21-2011, 03:37 PM   #1 (permalink)
Just Some Guy
 
Join Date: Dec 2010
Posts: 112
UnretroGamer is on a distinguished road
Smile Simple IBAction crashes app. Why?

I assigned an IBAction to a button that all it does (for now) is an NSLog saying "Entered" like this:

Code:
- (void) enter {
	NSLog(@"Entered");
}
When I press the button in the app, the console says the following:
Code:
2011-01-21 17:30:00.495 LoL[1805:207] -[UIViewController enter]: unrecognized selector sent to instance 0x5f109f0
2011-01-21 17:30:00.497 LoL[1805:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController enter]: unrecognized selector sent to instance 0x5f109f0'
*** Call stack at first throw:
(
	0   CoreFoundation                      0x02490b99 __exceptionPreprocess + 185
	1   libobjc.A.dylib                     0x025e040e objc_exception_throw + 47
	2   CoreFoundation                      0x024926ab -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
	3   CoreFoundation                      0x024022b6 ___forwarding___ + 966
	4   CoreFoundation                      0x02401e72 _CF_forwarding_prep_0 + 50
	5   UIKit                               0x002c27f8 -[UIApplication sendAction:to:from:forEvent:] + 119
	6   UIKit                               0x004ce68b -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 156
	7   UIKit                               0x002c27f8 -[UIApplication sendAction:to:from:forEvent:] + 119
	8   UIKit                               0x0034dde0 -[UIControl sendAction:to:forEvent:] + 67
	9   UIKit                               0x00350262 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
	10  UIKit                               0x0034ee0f -[UIControl touchesEnded:withEvent:] + 458
	11  UIKit                               0x002e63d0 -[UIWindow _sendTouchesForEvent:] + 567
	12  UIKit                               0x002c7cb4 -[UIApplication sendEvent:] + 447
	13  UIKit                               0x002cc9bf _UIApplicationHandleEvent + 7672
	14  GraphicsServices                    0x02d70822 PurpleEventCallback + 1550
	15  CoreFoundation                      0x02471ff4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
	16  CoreFoundation                      0x023d2807 __CFRunLoopDoSource1 + 215
	17  CoreFoundation                      0x023cfa93 __CFRunLoopRun + 979
	18  CoreFoundation                      0x023cf350 CFRunLoopRunSpecific + 208
	19  CoreFoundation                      0x023cf271 CFRunLoopRunInMode + 97
	20  GraphicsServices                    0x02d6f00c GSEventRunModal + 217
	21  GraphicsServices                    0x02d6f0d1 GSEventRun + 115
	22  UIKit                               0x002d0af2 UIApplicationMain + 1160
	23  LoL                                 0x00002024 main + 102
	24  LoL                                 0x00001fb5 start + 53
)
terminate called after throwing an instance of 'NSException'
What is wrong?
UnretroGamer is offline   Reply With Quote
Old 01-21-2011, 03:52 PM   #2 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 46
kasparp is on a distinguished road
Default

It could be that you have not selected your own ViewController class as 'Files Owner' instead of generic UIViewController in Interface builder (its under Object identity in properties pane if you select files owner).

Edit: Actually i am not really sure, probably should'nt have answered, consider it a bump
__________________
Cheers
kasparp is offline   Reply With Quote
Old 01-21-2011, 03:57 PM   #3 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Code:
'-[UIViewController enter]: unrecognized selector sent to instance 0x5f109f0'
The object type on the left -- UIViewController -- doesn't know how to handle the message on the right -- enter.

You either have the wrong object, or the wrong message. Or potentially a memory issue.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 01-21-2011, 04:03 PM   #4 (permalink)
Just Some Guy
 
Join Date: Dec 2010
Posts: 112
UnretroGamer is on a distinguished road
Default

Quote:
Originally Posted by kasparp View Post
It could be that you have not selected your own ViewController class as 'Files Owner' instead of generic UIViewController in Interface builder (its under Object identity in properties pane if you select files owner).

Edit: Actually i am not really sure, probably should'nt have answered, consider it a bump
Nope I set the ViewController which I set the IBAction as the File's Owner. Thanks anywho.
UnretroGamer is offline   Reply With Quote
Old 01-21-2011, 04:04 PM   #5 (permalink)
Just Some Guy
 
Join Date: Dec 2010
Posts: 112
UnretroGamer is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
Code:
'-[UIViewController enter]: unrecognized selector sent to instance 0x5f109f0'
The object type on the left -- UIViewController -- doesn't know how to handle the message on the right -- enter.

You either have the wrong object, or the wrong message. Or potentially a memory issue.
What should I do to fix it?
UnretroGamer is offline   Reply With Quote
Old 01-21-2011, 04:04 PM   #6 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Send the right message to the right object.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 01-21-2011, 04:14 PM   #7 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

How is 'enter' method declared in the header file? Probably as IBAction. Does it make a difference that in the implementation it void?
Check the connection in IB. Right click on file owner and see in the popup if there's anything wrong.
baja_yu is offline   Reply With Quote
Old 01-21-2011, 04:19 PM   #8 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Quote:
Originally Posted by baja_yu View Post
How is 'enter' method declared in the header file? Probably as IBAction. Does it make a difference that in the implementation it void?
Check the connection in IB. Right click on file owner and see in the popup if there's anything wrong.
IBAction is void, it just makes the method appear in IB. If it isn't an IBAction in the .h, then you won't have access to it to make a connection anyway.

I just verified that if the .m says void while the .h says IBAction, everything works just fine.

I'm thinking the issue is along the lines of what kasparp said.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 01-21-2011, 05:08 PM   #9 (permalink)
Just Some Guy
 
Join Date: Dec 2010
Posts: 112
UnretroGamer is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
IBAction is void, it just makes the method appear in IB. If it isn't an IBAction in the .h, then you won't have access to it to make a connection anyway.

I just verified that if the .m says void while the .h says IBAction, everything works just fine.

I'm thinking the issue is along the lines of what kasparp said.
Well I'm guessing Kasparp was saying to set the ViewController under File's Owner > Identity [Tab] > Class Identity > Class. Which I did, unless that's not what he was talking about...
UnretroGamer is offline   Reply With Quote
Old 01-21-2011, 05:08 PM   #10 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

What did you set it to?
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 01-21-2011, 05:27 PM   #11 (permalink)
Just Some Guy
 
Join Date: Dec 2010
Posts: 112
UnretroGamer is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
What did you set it to?
The ViewController that declares the IBAction
UnretroGamer is offline   Reply With Quote
Old 01-21-2011, 05:28 PM   #12 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Ok.

I don't know what else to tell you that hasn't already been said.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 01-21-2011, 05:37 PM   #13 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
JasonR is on a distinguished road
Default

According to the error message, the IBAction is being sent to a generic UIViewController, not the one you made. I would recommend you post the following if you want help:

the .h file for your view controller class.
Exactly what you typed in for "Files Owner".
Any other code used to create this view controller.

Without more info, we have no idea what the problem could be.
JasonR is offline   Reply With Quote
Old 01-21-2011, 07:56 PM   #14 (permalink)
Just Some Guy
 
Join Date: Dec 2010
Posts: 112
UnretroGamer is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
Ok.

I don't know what else to tell you that hasn't already been said.
[ANSWER] Oh man I figured out the problem! You guys helped me by telling me it was set to a generic View Controller. Doing some mindless digging, I went into the List View Mode in Interface Builder and all I had to do was select each view under the Tab Bar Controller and connect it to my ViewController class under the Identity tab. Not the Tab Bar Items.

......88.......
......88.......
......88.......
......88.......
......88.......
888888888
..8888888..
....88888....
......888.....
........8.......

P.S. I've loaded a view like this:
Code:
[window addSubview:mainMenuTabBarController.view];
Where mainMenuTabBarController is a tabBarController implemented in it's header file. How though, do I add a subview from a viewController class? When I try to like this:
Code:
[window addSubview:Sandbox.view];
It says obviously, 'Sandbox' undeclared. How would I about doing this? Adding a subview from a viewController class.

If you wish to answer this, I posted a thread which you can reply to here: http://www.iphonedevsdk.com/forum/ip...ler-class.html

Last edited by UnretroGamer; 01-21-2011 at 11:19 PM.
UnretroGamer is offline   Reply With Quote
Reply

Bookmarks

Tags
button, ibaction, nslog

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 360
10 members and 350 guests
7twenty7, dre, iAppDeveloper, jeroenkeij, Mah6447, Morrisone, sacha1996, Sami Gh, stanny, toon4413
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:42 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0