FROM : Jim Correia
DATE : Tue Jul 18 18:11:27 2006
On Jul 17, 2006, at 9:00 PM, Chris Kane wrote:
> If you assume that @"" string constants are NOT globally uniqued in
> a binary, but only to a given compilation unit, then
> ThisClassUniqueObservationContext could be a constant string:
>
> static NSString * ThisClassUniqueObservationContext = @"MyContext";
Even if the strings are globally uniqued across the entire binary,
assuming a FBFroobazle class, something like this is probably good
enough:
static NSString * FBFroobazzleValueObservationContext =
@"FBFroobazzleValueObservationContext";
Certainly better than
static void * FBFroobazzleValueObservationContext = (void *)2192;
There is the chance that someone else will use the string
@"FBFroobazzleValueObservationContext" as an observation context
elsewhere in the inheritance tree, but I think that a) it would be a
programmer error b) is probably not worth losing any sleep over.
And there is certainly a smaller chance of a collision than with an
arbitrarily picked number.
Jim
DATE : Tue Jul 18 18:11:27 2006
On Jul 17, 2006, at 9:00 PM, Chris Kane wrote:
> If you assume that @"" string constants are NOT globally uniqued in
> a binary, but only to a given compilation unit, then
> ThisClassUniqueObservationContext could be a constant string:
>
> static NSString * ThisClassUniqueObservationContext = @"MyContext";
Even if the strings are globally uniqued across the entire binary,
assuming a FBFroobazle class, something like this is probably good
enough:
static NSString * FBFroobazzleValueObservationContext =
@"FBFroobazzleValueObservationContext";
Certainly better than
static void * FBFroobazzleValueObservationContext = (void *)2192;
There is the chance that someone else will use the string
@"FBFroobazzleValueObservationContext" as an observation context
elsewhere in the inheritance tree, but I think that a) it would be a
programmer error b) is probably not worth losing any sleep over.
And there is certainly a smaller chance of a collision than with an
arbitrarily picked number.
Jim






Cocoa mail archive

