Skip navigation.
 
mlRe: When are bound variables initialized?
FROM : Kevin Ballard
DATE : Tue Apr 12 22:11:13 2005

Umm, you can't call -setString: on a nil object.

I think -awakeFromNib is too late to be setting them directly without 
using the KVO methods I mentioned or using the setter.

I suggest you set it in your -init method instead. And use

awakeFromNib = [[NSMutableString alloc] initWithString:@"Distance"];

And then in your -dealloc you need to add

[awakeFromNib release];

Don't forget to call [super dealloc] at the end of your -dealloc method.

Also, it's probably not going to work how you expect, using a mutable 
ivar as the target for an interface binding. Each time you modify the 
string, you'd have to notify the binding that you changed it with 
those 2 methods I mentioned earlier, or it won't work. I suggest 
instead using a regular NSString and just changing it. And if you do 
that, then you could even simply use [self setValue:@"Distance" 
forKey:@"selectedXAxisValue"] instead of setting it directly or using 
those 2 methods I mentioned earlier (the -willChangeValueForKey: and -
didChangeValueForKey:)

On Apr 12, 2005, at 4:05 PM, Michael Lutz wrote:

> Well, I try to initialize it in awakeFromNib: [selectedXAxisValue 
> setString:@"Distance"];
> But at that point of time the Chart window was not displayed the 
> first time. And so selectedXAxisValue is nil and the setString 
> message has no effect.
> So my question is: When changes the selectedXAxisValue from nil to 
> a real object? Or do i have to alloc] init] it? I tried it once but 
> I remember I got some signal error when I released it in 
> AppController's dealloc method.


--
Kevin Ballard
<email_removed>
http://www.tildesoft.com
http://kevin.sb.org

Related mailsAuthorDate
mlWhen are bound variables initialized? Michael Lutz Apr 12, 20:34
mlRe: When are bound variables initialized? Kevin Ballard Apr 12, 21:34
mlRe: When are bound variables initialized? Michael Lutz Apr 12, 22:05
mlRe: When are bound variables initialized? Kevin Ballard Apr 12, 22:11
mlRe: When are bound variables initialized? Michael Lutz Apr 13, 22:21
mlRe: When are bound variables initialized? Scott Anguish Apr 13, 23:38