On Jun 15, 2016, at 16:34 , Graham Cox <graham....@bigpond.com> wrote: > > If the property is ‘isFoo’, then in every situation (such as KVO, or using > dot syntax) I would be using the keypath “isFoo”, and that’s fine, but it’s > inconsistent with other properties that are not readonly, where the > underlying property is ‘foo’, but in some code I’d use ‘isFoo’ and other > times I’d just use ‘foo’. However, if I try and make that consistent, by > having the property ‘foo’ and a custom getter ‘isFoo’, then for a readonly > property it seems a bit redundant.
You may be overthinking that. From the documentation, here’s what happens with 'valueForKey:<key>’: > Default Search Pattern for valueForKey: > > When the default implementation of valueForKey: is invoked on a receiver, the > following search pattern is used: > > • Searches the class of the receiver for an accessor method whose name > matches the pattern get<Key>, <key>, or is<Key>, in that order. https://developer.apple.com/library/prerelease/content/documentation/Cocoa/Conceptual/KeyValueCoding/Articles/SearchImplementation.html That is, if the property is “foo”, it doesn’t matter whether the getter is “foo” or “isFoo”, though the setter needs to be “setFoo:". (If the property is “isFoo”, then the getter and setter must be “isFoo” and “setIsFoo:”.) _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com