Re: Class vs +class: Cocoa/Obj-C design question
Re: Class vs +class: Cocoa/Obj-C design question
- Subject: Re: Class vs +class: Cocoa/Obj-C design question
- From: Bill Bumgarner <email@hidden>
- Date: Mon, 15 Oct 2007 23:51:09 -0500
On Oct 15, 2007, at 11:23 PM, Chris Suter wrote:
But, after posing, there's still no difference between using
NSObject and [NSObject class] so it doesn't prove that there are
cases where
NSObject != [NSObject class]
Can you think of another example that does?
I'm not sure what you are asking.
NSObject, by itself, cannot be used syntactically within Objective-C
except as the target of method invocations.
The following does not compile:
NSLog(@"Foo 0x%x", NSObject);
If the question is of a "what if" nature. As in: "What if NSObject
could be used as in a context like the above (or in NSObject ==
NSArray)?", then the answer would be an implementation detail.
Most likely, it would mean one of two things:
(1) a bare "NSObject" would turn into an equivalent to [NSObject class]
(2) a bare "NSObject" would turn into a value defined at link time to
point to the NSObject class (likely through one level of indirection
as per most dylib flavored symbols)
If (1), then -- no -- no difference.
If (2), then -- yes -- huge difference.
If Objective-C on OS X were to support such a pattern, it would likely
fall be in the style of (1). It is consistent and will lead to
implementations of least surprise.
b.bum
(Of course, a cached variable containing the result of [NSObject
class] will quite nicely demonstrate the potential inconsistencies of
(2)).
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden