FROM : Michael Lutz
DATE : Wed Apr 13 22:21:43 2005
Yup, I did know that I can't call -setString: on a nil object. I got
confused because the variable was initialized after the windows was
shown the first time. So I was unsure if I am responsible for alloc]
init] it or not.
But your comments cleared things up for me. Now I understand that each
change in the views causes an accessor set call for selectedXAxisValue,
which makes it clear why it is initialized after the first time the
window is shown and why I am safe allocing it myself. The error I
mentioned before (the one I got when I tried to alloc it myself) was
because I called [selectedXAxisValue dealloc] instead of
[selectedXAxisValue release]. That's what you get form late night
programming :(
Thanks for your help. Now I am about to figure out why my
triggerChangeNotificationsForDependentKey is not working. ;)
Cheers,
Michael
On Apr 12, 2005, at 22:11, Kevin Ballard wrote:
> 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
>
DATE : Wed Apr 13 22:21:43 2005
Yup, I did know that I can't call -setString: on a nil object. I got
confused because the variable was initialized after the windows was
shown the first time. So I was unsure if I am responsible for alloc]
init] it or not.
But your comments cleared things up for me. Now I understand that each
change in the views causes an accessor set call for selectedXAxisValue,
which makes it clear why it is initialized after the first time the
window is shown and why I am safe allocing it myself. The error I
mentioned before (the one I got when I tried to alloc it myself) was
because I called [selectedXAxisValue dealloc] instead of
[selectedXAxisValue release]. That's what you get form late night
programming :(
Thanks for your help. Now I am about to figure out why my
triggerChangeNotificationsForDependentKey is not working. ;)
Cheers,
Michael
On Apr 12, 2005, at 22:11, Kevin Ballard wrote:
> 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 mails | Author | Date |
|---|---|---|
| Michael Lutz | Apr 12, 20:34 | |
| Kevin Ballard | Apr 12, 21:34 | |
| Michael Lutz | Apr 12, 22:05 | |
| Kevin Ballard | Apr 12, 22:11 | |
| Michael Lutz | Apr 13, 22:21 | |
| Scott Anguish | Apr 13, 23:38 |






Cocoa mail archive

