• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: When are bound variables initialized?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: When are bound variables initialized?


  • Subject: Re: When are bound variables initialized?
  • From: Kevin Ballard <email@hidden>
  • Date: Tue, 12 Apr 2005 16:11:13 -0400

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@hidden http://www.tildesoft.com http://kevin.sb.org

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: When are bound variables initialized?
      • From: Michael Lutz <email@hidden>
References: 
 >When are bound variables initialized? (From: Michael Lutz <email@hidden>)
 >Re: When are bound variables initialized? (From: Kevin Ballard <email@hidden>)
 >Re: When are bound variables initialized? (From: Michael Lutz <email@hidden>)

  • Prev by Date: Detecting Double Byte Input
  • Next by Date: NSWindow question.
  • Previous by thread: Re: When are bound variables initialized?
  • Next by thread: Re: When are bound variables initialized?
  • Index(es):
    • Date
    • Thread