• 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: Usage of +class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Usage of +class


  • Subject: Re: Usage of +class
  • From: Jonathon Mah <email@hidden>
  • Date: Sun, 23 Apr 2006 01:12:07 +0930

On 2006-04-22, at 19:17, j o a r wrote:

Not really. You can find the answer in The Fine Manual:

Ah, thanks joar. To sumarize:

A class identifier has two uses: a _type_, and a message receiver. Contrast this to a variable, which has two uses: a _value_, and a message receiver.

e.g.

{
NSString *str; // Class used as a type
NSLog(@"Class address: %u", [NSString class]); // Class used as a receiver
NSLog(@"Class address: %u", NSString); // INVALID: NSString has no value


id obj = [NSArray array];
NSLog(@"Object address: %u", obj); // Object used as a value
NSLog(@"Object description: %@", [obj description]); // Object used as a receiver
obj *blah; // INVALID (obviously): obj is not a type
}



Interestingly, you can change the use of a class name from a type to a value:


{
    Class temp = [NSString class];
    void *NSString = temp;

NSString *str; // INVALID: NSString is not a type
NSLog(@"Class address: %u", [NSString class]); // Valid (but warning)
NSLog(@"Class address: %u", NSString); // Valid
}



I think I've beaten this to death now.


Jonathon Mah email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Usage of +class
      • From: Ondra Cada <email@hidden>
    • Re: Usage of +class
      • From: j o a r <email@hidden>
References: 
 >Usage of +class (From: Jonathon Mah <email@hidden>)
 >Re: Usage of +class (From: j o a r <email@hidden>)

  • Prev by Date: Keyboard Events in Modal NSWindow
  • Next by Date: init code for new document only
  • Previous by thread: Re: Usage of +class
  • Next by thread: Re: Usage of +class
  • Index(es):
    • Date
    • Thread