• 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: where have all the IVARS gone? (long time passing...)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: where have all the IVARS gone? (long time passing...)


  • Subject: Re: where have all the IVARS gone? (long time passing...)
  • From: John Sarkela <email@hidden>
  • Date: Fri, 7 Jul 2006 11:42:11 -0700


I suspect you are detecting a common pattern of usage in the Foundation framework. In this case, the instance variables you seek have not yet been declared. They will be declared in concrete subclasses of NSString.


When you create an instance of an NSString you are almost never getting an NSString instance as a result. There are a number of highly optimized subclasses, one of which will be the concrete class of your instance. For example, I commonly will see instances of NSCFString in the debugger. These instances conform to the NSString protocol and thus may be used interchangeably. By design, the framework designers have not published the declarations for the "hidden" concrete subclasses.

This pattern comes from a pattern in the Smalltalk base library in which an abstract superclass provides a set of instance creation methods that return instances of appropriate concrete subclasses.

To learn more about how to code Foundation like classes, you may wish to visit www.gnustep.org. You can download code for an open source implementation of the Foundation framework. This will let you peruse not only headers, but implementations as well. IIRC, it was Adele Goldberg who made source code browsers a first priority for the Smalltalk IDE. This is because the best coders spend at least 80% of their time reading.

John Sarkela
Knight of the Square Brackets [|]

On Jul 7, 2006, at 10:09 AM, email@hidden wrote:


I'm new to Cocoa & Objective-C, and I've been randomly going through the header files in the Foundation framework just to get a feel for how Objective-C header files are written, and I've noticed that there seem to be no instance variables declared anywhere.

I understand the concept of encapsulation; I'm not looking for
instance variables to use them, but rather to see how "real"
Objective-C classes are designed. So how do classes like NSString,
NSSet or NSValue manage their internal state? Like Michael Palin once
said (or would have, had he been a developer)

"You wouldn't get very far in life if your class instances have no
internal state."

Is there some secret way of having instance variables and not
declaring them in the interface files?


Rob Ross




_______________________________________________ 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
  • Prev by Date: Re: NSDate in a Range
  • Next by Date: Re: A problem of NSImageView
  • Previous by thread: Re: where have all the IVARS gone? (long time passing...)
  • Next by thread: more on two-way bindings and one-way bindings
  • Index(es):
    • Date
    • Thread