• 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: Controller Layer and Automatic Key-Value Observing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Controller Layer and Automatic Key-Value Observing


  • Subject: Re: Controller Layer and Automatic Key-Value Observing
  • From: Henrik Wittland <email@hidden>
  • Date: Sat, 8 Nov 2003 00:57:14 +0100

Am 07.11.2003 um 23:41 schrieb Frank Illenberger:

Has anybody successfully managed to use the automatic key-value
observing with attributes that are bound in IB???

YES

I constructed bindings between attributes in my NSDocument and some
NSTextFields. I assumed that any programmatic changes to my model
variables via set-methods, direct assignments or takeValueForKey calls
should trigger the appropriate updates in the bound TextFields, but
this is not the case.

If you have a string property named "info" you can do this:

[self willChangeValueForKey:@"info"];
[info autorelease];
info = [[[NSCalendarDate calendarDate] description] retain];
[self didChangeValueForKey:@"info"];

or this :

[self setValue:[[NSCalendarDate calendarDate] description] forKey:@"info"];

or this :

-(NSString *)info {return info;}
-(void)setInfo:(NSString *)_info {[info autorelease];info = [_info retain];}

[self setInfo:[[NSCalendarDate calendarDate] description]];

but not this :

[self takeValue:[[NSCalendarDate calendarDate] description] forKey:@"info"];

and not this :

[info autorelease];
info = [[[NSCalendarDate calendarDate] description] retain];

Direct assignments of ivars realy do not work.
takeValue:forKey: does not work and is deprecated.

I always have to manually call willChangeValueForKey /
didChangeValueForKey for the controller to recognize the changes.

You have not used any controller in your example. Bindings from NSTextFields to the
File's Owner dont use any NSController. :-)

Regards,
Henrik
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Controller Layer and Automatic Key-Value Observing (From: Frank Illenberger <email@hidden>)

  • Prev by Date: Re: Parameters
  • Next by Date: Re: Parameter lists
  • Previous by thread: Controller Layer and Automatic Key-Value Observing
  • Next by thread: Controller Layer and Automatic Key-Value Observing
  • Index(es):
    • Date
    • Thread