Re: Xcode / Interface Builder creates nil binding of an NSTextField instance ...
Re: Xcode / Interface Builder creates nil binding of an NSTextField instance ...
- Subject: Re: Xcode / Interface Builder creates nil binding of an NSTextField instance ...
- From: Ken Thomases <email@hidden>
- Date: Sun, 20 Jun 2010 07:04:26 -0500
On Jun 19, 2010, at 6:15 PM, Jay Reynolds Freeman wrote:
> In IB, I drag an instance of NSTextField from the library onto my
> window, and use control-drag to hook it up to as instance of
> NSTextField in a controller, the instance being declared in that
> controller's header file. The IB Connections Inspector indicates
> that the binding is present and correct, and yes, I did remember
> to save from IB.
>
> On doing a clean and then a build of my project in Xcode, and then
> launching the app, I find that the declared instance is nil in
> "applicationDidFinishLaunching". That is, I instrumented along the
> lines of "if( <that instance> == nil ) NSLog(...)".
This sort of thing sometimes happens because you have two instance of your controller, by mistake. There's one that's instantiated in the NIB and, perhaps, you're instantiating one in code, too. The one in the NIB is connected to the NSTextField via its outlet, but the one you create in code is not its instance variables are left as zero/nil.
Put a log line in the -init method of the class. I bet you see it twice. Better yet, set a breakpoint on that method and make sure you understand the backtrace whenever it's called.
Good luck,
Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden