Re: NSString Class Instance Variables

2009-10-14 Thread Andy Lee

On Oct 14, 2009, at 3:39 AM, Ariel Feinerman wrote:

It seems interesting. If I want to create my own superclass for class
cluster, how can I implement it? Could you show simple example,
please?


Maybe Google knows?  


The first hit is 

--Andy

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString Class Instance Variables

2009-10-14 Thread Ariel Feinerman
It seems interesting. If I want to create my own superclass for class
cluster, how can I implement it? Could you show simple example,
please?

--
best regards
Ariel
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString Class Instance Variables

2009-10-13 Thread Graham Cox


On 14/10/2009, at 10:38 AM, Greg Parker wrote:

On 32-bit Mac, if you strip ivars from the header then other code  
cannot subclass that class. The compiler will put subclass and  
superclass ivars in the same place, leading to exciting data  
corruption bugs.


All system frameworks are honest about their ivars, because they  
need to support subclasses.





Yes, that makes perfect sense. I guess I was assuming that you would  
only be using a class 'as is', not subclassing it.


--Graham


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString Class Instance Variables

2009-10-13 Thread Greg Parker

On Oct 13, 2009, at 4:29 PM, Graham Cox wrote:

On 14/10/2009, at 6:40 AM, Richard Somers wrote:
The same is true for NSArray, NSSet, and other foundation classes.  
If the class has no instance variables, what does it do for storage?


Apart from the class cluster answer you already got, the public  
headers don't need to include any instance variables even if they  
exist in reality. You can do this yourself - compile the code using  
the 'real' headers then publish a public header that strips the  
ivars and only includes any public API you want to expose. It's a  
good habit to mark ivars as @private unless you really, really  
cannot avoid doing that, and if they are private there's no need to  
publish them.


On 32-bit Mac, if you strip ivars from the header then other code  
cannot subclass that class. The compiler will put subclass and  
superclass ivars in the same place, leading to exciting data  
corruption bugs.


All system frameworks are honest about their ivars, because they need  
to support subclasses.



--
Greg Parker gpar...@apple.com Runtime Wrangler


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString Class Instance Variables

2009-10-13 Thread Jens Alfke


On Oct 13, 2009, at 4:29 PM, Graham Cox wrote:

Apart from the class cluster answer you already got, the public  
headers don't need to include any instance variables even if they  
exist in reality.


Only if the class cannot be subclassed.

In the 32-bit runtime, instance variable offsets are determined at  
compile time based on the total size of superclass data, so if the  
compiler doesn't know all of the superclass instance variables, it'll  
generate incorrect code. (The 64-bit runtime doesn't have this  
limitation.)


—Jens

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString Class Instance Variables

2009-10-13 Thread Graham Cox


On 14/10/2009, at 6:40 AM, Richard Somers wrote:

The same is true for NSArray, NSSet, and other foundation classes.  
If the class has no instance variables, what does it do for storage?



Apart from the class cluster answer you already got, the public  
headers don't need to include any instance variables even if they  
exist in reality. You can do this yourself - compile the code using  
the 'real' headers then publish a public header that strips the ivars  
and only includes any public API you want to expose. It's a good habit  
to mark ivars as @private unless you really, really cannot avoid doing  
that, and if they are private there's no need to publish them.


--Graham


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString Class Instance Variables

2009-10-13 Thread David Duncan

On Oct 13, 2009, at 12:40 PM, Richard Somers wrote:

This might be a dumb question but just out of curiosity I was  
looking at NSString.h. The class appears to have no instance  
variables.



NSString is just an interface to a cluster of classes that implement  
the actual functionality, ditto for many other Foundation classes.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString Class Instance Variables

2009-10-13 Thread Stephen J. Butler
On Tue, Oct 13, 2009 at 2:40 PM, Richard Somers
 wrote:
> The same is true for NSArray, NSSet, and other foundation classes. If the
> class has no instance variables, what does it do for storage?


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSString Class Instance Variables

2009-10-13 Thread Richard Somers
This might be a dumb question but just out of curiosity I was looking  
at NSString.h. The class appears to have no instance variables.


/* NSString.h ... */

@interface NSString : NSObject 

- (NSUInteger)length;   
- (unichar)characterAtIndex:(NSUInteger)index;

@end

The same is true for NSArray, NSSet, and other foundation classes. If  
the class has no instance variables, what does it do for storage?


Richard

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com