Re: Sub classing.
Re: Sub classing.
- Subject: Re: Sub classing.
- From: Sandro Noel <email@hidden>
- Date: Tue, 5 Dec 2006 10:51:04 -0500
James, Marc.
Thank you!
The Cocoa Community is so helpful!
Category is exactly what i need.
Sandro Noel.
On 5-Dec-06, at 10:36 AM, James Bucanek wrote:
Sandro Noel wrote on Tuesday, December 5, 2006:
Am I doing this wrong ?
Yes. ;)
i want to create a Dataset for a table view, it's a simple one an the
values should be static.
so i declare .
@interface StatusTableDataset : NSMutableArray {
}
The problem here is that most of the core collection classes are
either class clusters or are bridges to Foundation objects. Short
answer: You can't subclass them.
Define your data model using in instance of NSMutableArray, not a
subclass of it.
@interface StatusTableDataset : NSObject {
@private
NSMutableArray* theData;
...
who should i inherit from to get all the nice functionality, and not
have to implement them myself ? :)
The other way of doing this is to create a catagory. You can use
this to tack your methods onto the implementation of NSMutableArray:
@interface NSMutableArray (StatusTableDataset) {
- (id)getStatusObjectAtIndex:(unsigned int)index;
...
Once you do that, you can send any instance of NSMutableArray the
message getStatusObject:. The only limitation of catagories is that
you can't add instance variables to the class, only methods.
--
James Bucanek
_______________________________________________
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