• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Class vs +class: Cocoa/Obj-C design question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Class vs +class: Cocoa/Obj-C design question
      • From: Chris Suter <email@hidden>
References: 
 >Class vs +class: Cocoa/Obj-C design question (From: Chris Ryland <email@hidden>)
 >Re: Class vs +class: Cocoa/Obj-C design question (From: Bill Bumgarner <email@hidden>)
 >Re: Class vs +class: Cocoa/Obj-C design question (From: Chris Ryland <email@hidden>)
 >Re: Class vs +class: Cocoa/Obj-C design question (From: Bill Bumgarner <email@hidden>)
 >Re: Class vs +class: Cocoa/Obj-C design question (From: Chris Suter <email@hidden>)

  • Prev by Date: Re: Class vs +class: Cocoa/Obj-C design question
  • Next by Date: Re: Class vs +class: Cocoa/Obj-C design question
  • Previous by thread: Re: Class vs +class: Cocoa/Obj-C design question
  • Next by thread: Re: Class vs +class: Cocoa/Obj-C design question
  • Index(es):
    • Date
    • Thread