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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 03-17-2010, 04:23 PM   #1 (permalink)
red
Registered Member
 
red's Avatar
 
Join Date: Jul 2009
Posts: 49
Default IBAction is crashing with no error in console

I am not new to the iPhone so I am confused why this IBAction code is failing.

I have a view controller with 2 buttons and 2 IBActions that are connected in Interface Builder. The view controller's view is added as a subview to another view. When I click a button the App crashes but nothing is printed to the console. The debugger doesn't show the line that causes the crash.

Any ideas what may cause this?
Thanks.
red is offline   Reply With Quote
Old 03-17-2010, 04:50 PM   #2 (permalink)
red
Registered Member
 
red's Avatar
 
Join Date: Jul 2009
Posts: 49
Default

If I push this view controller instead of adding it as a subview then the buttons work.
red is offline   Reply With Quote
Old 03-17-2010, 05:09 PM   #3 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 791
Default

Its action is most likely connected to its "File's Owner" in the xib file, that should be its view controller. Are you certain the view controller still lives at the point the button inside the view is being pushed? The button may be trying to call its action code on a released object.
nobre84 is offline   Reply With Quote
Old 03-17-2010, 07:04 PM   #4 (permalink)
red
Registered Member
 
red's Avatar
 
Join Date: Jul 2009
Posts: 49
Default

The file owner connects the IBActions to the buttons.
All view controllers are still being referenced correctly.
Quote:
Originally Posted by nobre84 View Post
Its action is most likely connected to its "File's Owner" in the xib file, that should be its view controller. Are you certain the view controller still lives at the point the button inside the view is being pushed? The button may be trying to call its action code on a released object.
red is offline   Reply With Quote
Old 03-17-2010, 07:34 PM   #5 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 4,814
Default Your view controller is likely being unloaded.

Quote:
Originally Posted by red View Post
The file owner connects the IBActions to the buttons.
All view controllers are still being referenced correctly.
nobre84 is probably on the right track.

By having your view controller's view inserted in another view, you are fighting against the way the UI kit is designed. It is intended to have view controllers manage a view that covers the entire screen, and have those view controllers pushed onto a navigation controller or managed by a tab view.

Your view controller is probably not being retained, and is being deallocated, or at least it's views are being unloaded.

To test this, add a -dealloc method and a -viewDidUnload to your view controller, and have both those methods write a message to the console using NSLog(). Also set breakpoints on those methods. I bet you will find that your view controller is being deallocated before you click the button.


Regards,

Duncan C
Duncan C is online now   Reply With Quote
Reply

Bookmarks

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: 351
19 members and 332 guests
ADY, Dani77, Duncan C, F_Bryant, Grinarn, HemiMG, Herbie, jansan, JasonR, linkmx, macquitzon216, mer10, Monstertaco, prchn4christ, Robiwan, sly24, Touchmint, twerner, zulfishah
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,760
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

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