On Aug 29, 2008, at 10:03 AM, Phil wrote:
On Sat, Aug 30, 2008 at 2:56 AM, Dave Dribin <[EMAIL PROTECTED]> wrote:
Is there some benefit to using number values over string constants, or is it
just stylistic differences?


Using NSStrings (or any other object) will work fine, but comparing
two primitive numbers is a lot faster than comparing to strings.

As long as the pointers point to unique objects (and they remain valid even in a GC world), you just need to compare their pointer value. So even with this:

static NSString *PropertyObservationContext = @"Property Context";

You can still check (context == PropertyObservationContext) in observeValueForKeyPath:ofObject:change:context:.

Personally, I wouldn't use arbitary numbers for any pointer value
(even a context variable like this), but that's just my stylistic
difference.

I generally wouldn't either, unless there's some benefit I'm not seeing.

-Dave

_______________________________________________

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]

Reply via email to