• 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: observing dealloc
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: observing dealloc


  • Subject: Re: observing dealloc
  • From: Ken Tozier <email@hidden>
  • Date: Tue, 29 May 2007 00:08:39 -0400


On May 28, 2007, at 11:28 PM, Chris Hanson wrote:

One further distinction to make is whether you're dealing with true "class variables" or with "class instance variables." A class can be thought of as just another object; a class instance variable is an instance variable of the class object. The difference between the two is that if you have class A and class B which is a subclass of A, they each share the *same* class variables but because each class is a distinct object they each get *their own copy* of each class instance variable.

Let me see if I have this right. Given two classes "MyBaseClass" and MySubClass


@interface MyBaseClass : NSObject
@end

@implementation MyBaseClass

NSMutableDictionary		gGlobals	= nil;

+ (void) initialize
{
	if (gGlobals == nil)
	{
		gGlobals = [[NSMutableDictionary alloc] init];
	}
}

@end


@interface MySubClass : MyBaseClass @end

MyBaseClass	*a		= [[MyBaseClass alloc] init];
MySubClass		*b		= [[MySubClass alloc] init];

The "gGlobals" variable for "a" would be distinct from the "gGlobals" for "b" correct?

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: observing dealloc
      • From: Chris Hanson <email@hidden>
    • Re: observing dealloc
      • From: Chris Suter <email@hidden>
References: 
 >Re: observing dealloc (From: Erik Buck <email@hidden>)
 >Re: observing dealloc (From: Ken Tozier <email@hidden>)
 >Re: observing dealloc (From: Steve Israelson <email@hidden>)
 >Re: observing dealloc (From: Ken Tozier <email@hidden>)
 >Re: observing dealloc (From: Chris Hanson <email@hidden>)

  • Prev by Date: Re: CD: Creating a managed object
  • Next by Date: Re: observing dealloc
  • Previous by thread: Re: observing dealloc
  • Next by thread: Re: observing dealloc
  • Index(es):
    • Date
    • Thread