On Wed, Mar 5, 2008 at 4:14 PM, mmalc crawford <[EMAIL PROTECTED]> wrote: > > On Mar 5, 2008, at 1:40 PM, Adam P Jenkins wrote: > > > If you define a @property in the interface, then in the > > implementation you either need use @synthesize to have the compiler > > automatically generate a getter and setter, or use @dynamic to > > inform the compiler that you will provide the appropriately named > > getter and setter methods. > > > There is no *need* to specify @dynamic. In fact, doing so will > conceal a bug (at least until runtime...) if you don't intend to > create the appropriate methods at runtime (as do, for example, managed > objects) but forget to provide an implementation. If you don't > specify @dynamic, then the compiler will warn you if you don't supply > appropriate methods at compile time. > > > > If you need to define the accessors yourself because the auto- > > generated ones don't do what you want, then use @dynamic instead > > like this: > > @implementation Person > > @dynamic firstName; > > > > - (NSString*)firstName { ... } > > - (void)setFirstName:(NSString *)newName { ... } > > @end > > It's perfectly reasonable also to do either: > > > @implementation Person > > > - (NSString*)firstName { ... } > - (void)setFirstName:(NSString *)newName { ... } > @end > > > or, for example: > > > @implementation Person > @synthesize firstName; > > > - (void)setFirstName:(NSString *)newName { ... } > @end > > > In the latter case, the compiler will just synthesise -firstName. > > > One further issue for the sake of raising it: > > > @property (setter=mySetMethod:,getter=myMethod) id valueTest; > > > > Note that this implies that the accessor methods are atomic. It's > comparatively rare (unless you're using GC) that Cocoa developers > implement atomic accessor methods, so you'd typically specify: > > @property (nonatomic, setter=mySetMethod:,getter=myMethod) id valueTest; > > > mmalc >
Ok first, mmalc, thank you for taking the time to point out exactly what I needed to see to understand where I was going wrong. My problem stemmed from the misguided idea that properties were required for KVC/KVO. Chris' comment about "using non-default names" makes much more sense now. Second, for my situation, I ended up with an interface that looks like this: @property (getter=getValueForBindings, setter=setValueForBindings:, assign, nonatomic) id value; And an implementation: -(void) setValueForBindings:(id)_value { [self willChangeValueForKey:@"value"]; { BOOL didSetOK = [self setStringValue:(NSString *)_value]; // Do something with didSetOK } [self didChangeValueForKey:@"value"]; } -(id) getValueForBindings { return( value ); } Then binding my interface to the key 'valueForBindings'. Not the prettiest, but it's required for my situation. Thanks again to everyone for all the help. -- Jim http://nukethemfromorbit.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]