Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > NSButton woes

NSButton woes
Thread Tools
Fresh-Faced Recruit
Join Date: Mar 2000
Location: Pittsburgh, PA, USA
Status: Offline
Reply With Quote
Mar 6, 2002, 10:05 AM
 
I'm having an odd problem disabling an NSButton in my program. The button's name is bidButton, and I'm sending it a [bidButton setEnabled:NO] message, but it's not responding. I've used NSLog to verify that my program is indeed making it to this step.

To make sure I was not going crazy, I created a new program and tried to disable a button using the same method, and it worked fine. Would anyone know any reason why [bidButton setEnabled:NO] would fail to disable the button? I've also tried [bidButton performClick:bidButton] with no result either. Help!
     
Junior Member
Join Date: Mar 2001
Status: Offline
Reply With Quote
Mar 6, 2002, 12:06 PM
 
Sounds like bidButton is nil. If it's an IBOutlet, make sure that it's spelled the same in both Project Builder and Interface Builder, and that it's connected; you may also want to check its value in the debugger, or print it out right before hand.

-Peter
     
Fresh-Faced Recruit
Join Date: Mar 2000
Location: Pittsburgh, PA, USA
Status: Offline
Reply With Quote
Mar 6, 2002, 02:14 PM
 
Hmmm..... just checked, and indeed bidButton is nil. I created the NSButton in IB, and all the connections are correct, and I declared it as an IBOutlet.... what am I missing?
     
Fresh-Faced Recruit
Join Date: Mar 2002
Status: Offline
Reply With Quote
Mar 6, 2002, 02:49 PM
 
If u try to send a message to a button in the init method, the button may be nill. This is because when the nib file is loaded all the objects are created and sent the init method BEFORE connections are made. This is confusing. The way to work around this is to use the -awakeFromNib method which gets called after all connections are set.
Hope this helps
     
Fresh-Faced Recruit
Join Date: Mar 2000
Location: Pittsburgh, PA, USA
Status: Offline
Reply With Quote
Mar 6, 2002, 09:29 PM
 
ok... i thought i might be going insane for a bit there, but i'm not. So I did a bit of investigating and testing, and here's what's happening.

All the buttons in my app keep becoming nil, for no reason whatsoever. I try to interact with them in awakeFromNib and later on, by sending [buttonName setEnabled:false] messages, but they don't respond. If I delete the GUI button in IB, delete the outlet, and recreate the GUI button, recreate the outlet, and reconnect them it works fine... until it breaks again... Is anyone else having this problem? It's driving me completely insane, and is ruining what started as a pleasant programming experience.

Any help is appreciated. Thanks!
     
Forum Regular
Join Date: Jul 2001
Location: Québec, Canada
Status: Offline
Reply With Quote
Mar 9, 2002, 08:13 AM
 
I think I had a similar problem with a Preference pane once. All outlets where ok in IB, no error message on the console, but none of my controls where connected. Actions got connected however. I've even rebuilt the nib entierly with no effect.

Finaly, after two weeks I gave up and made some code in awakeFromNib that manualy connect outlets based on tags I've put in IB.

Well, at least now Gamma Control works!
     
   
Thread Tools
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -5. The time now is 12:14 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2