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 > Odd nil problems with GUI connections

Odd nil problems with GUI connections
Thread Tools
Mac Elite
Join Date: Sep 2000
Location: Norfolk, Va
Status: Offline
Reply With Quote
Jun 9, 2003, 01:53 PM
 
I have a window with an NSTextField in it connected to my controller object. But at applicationDidFinishLoading: when I try to setStringValue:@"Hello!" the textfield, it does nothing. Upon debugging, it's showing textField as nil.

Any ideas?
you are not your signature
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Jun 9, 2003, 02:28 PM
 
Originally posted by Gametes:
I have a window with an NSTextField in it connected to my controller object. But at applicationDidFinishLoading: when I try to setStringValue:@"Hello!" the textfield, it does nothing. Upon debugging, it's showing textField as nil.

Any ideas?
Make sure that the name of your outlet in IB is the same thing as your name in PB. If you're not already, I'd suggest using IBOutlet before you declare instance variables and IBAction as the return type for instance methods so that you can use IB to read the header files and create the outlets and actions for you, avoiding the problem where you needed an outlet or method one thing in your header file and something else in IB.

If that's not your problem, I'd probably have to look at your code to figure it out.

Hope this helps,
Matt Fahrenbacher
     
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status: Offline
Reply With Quote
Jun 9, 2003, 05:33 PM
 
If your outlet is named something like "widget" and the class you're connecting it to has a method named "setWidget:", that will be called automatically to connect the outlet. If your setWidget: method is meant to do something completely different, the outlet won't be connected.

This has happened to me a few times. For example, say that you're subclassing NSButton so that it'll stay synced with some NSTextField that contains the title of your document. You give your NSButton subclass a 'title' outlet and connect it to whatever.

Well, it never gets connected because NSButton responds to setTitle, and that gets called to set the outlet.

This can be a bitch to track down.
Geekspiff - generating spiffdiddlee software since before you began paying attention.
     
Gametes  (op)
Mac Elite
Join Date: Sep 2000
Location: Norfolk, Va
Status: Offline
Reply With Quote
Jun 10, 2003, 03:46 AM
 
It's the stragest thing really. I've deleted, renamed, reimported, and reconnected all of these things and still no go.
On top of this, my userdefaults won't write!

NSUserDefaults *defaults = [[NSUserDefaults standardUserDefaults] retain];
[defaults setObject:@"Yo" forKey:@"Momma"];

nuthin shows up in the save file except my toolbar setup and some audio preference?!
you are not your signature
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Jun 10, 2003, 04:04 AM
 
1. Have you tried calling synchronize?
2. It isn't really necessary to retain the standardUserDefaults object. It's not going anywhere.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Jun 10, 2003, 11:44 AM
 
Originally posted by Chuckit:
1. Have you tried calling synchronize?
2. It isn't really necessary to retain the standardUserDefaults object. It's not going anywhere.
1. What Chuckit is saying is that defaults don't get written out to file every time you add data to the defaults dictionary in active memory. It usually gets written out every 5 minutes, and it also gets written out when your application quits. So either quit your application or synchronize your defaults (which writes out the defaults now) and then you should be good to go. If not, then your system does have some serious problems, and I would suggest a reboot - that's fixed problems for me when things like the Font Server crash.

2. Well, it depends if he wants to keep a reference to it for later on. Although the shared instance will probably stick around because [NSUserDefaults sharedUserDefaults] probably returns a non-autoreleased object, I still think it's good programming style to retain stuff when it's passed to you and autorelease it when you're done with it (assuming that you're holding on to the object for some period of time).
     
Gametes  (op)
Mac Elite
Join Date: Sep 2000
Location: Norfolk, Va
Status: Offline
Reply With Quote
Jun 10, 2003, 12:21 PM
 
I retain it because I use it in loadPrefs and savePrefs methods which get called before riskier operations
In savePrefs I have [prefs synchronize], so yes it's there. I dunno, I guess I'll reboot. But are there cases where changing bundle identifiers and stuff after you creat the project has caused this problem? Maybe I've forgotten some step somewhere?

Wait, stop the presses! The defaults problem is fixed, who knows how. now about that lame connection...
you are not your signature
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Jun 10, 2003, 02:03 PM
 
Without the source, this is going to be hard to debug...

Matt Fahrenbacher
     
   
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 03:41 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