Re: Subclassing NSString
Re: Subclassing NSString
- Subject: Re: Subclassing NSString
- From: Ali Ozer <email@hidden>
- Date: Sat, 16 Jun 2001 12:33:49 -0700
>
And I don't think your objects is really a string when it has a
>
ProcessSerialNumber. I think you should use the following:
>
>
//ModelApp.h
>
@interface ModelAppObject : NSString
>
{
>
ProcessSerialNumber psn;
>
NSString *string;
>
}
Yes, this is a better approach; but I think you meant
@interface ModelAppObject : NSObject
that is, subclass of NSObject, not NSString.
In any case, yes, you do not want to subclass NSString to make it into
something else; you typically subclass NSString to provide alternate
implementations. That is because NSString is simply a unichar array +
length; add other attributes and it's no longer an NSString. That is why
NSAttributedString is not a subclass of NSString, for instance.
Ali