Class clusters - infinite loop?
Class clusters - infinite loop?
- Subject: Class clusters - infinite loop?
- From: Steve Canfield <email@hidden>
- Date: Fri, 24 Jun 2005 23:08:54 -0700
This is a repost from what I just posted to
comp.sys.mac.programmer.help, but I thought cross posting might be
helpful.
I'm trying to create a class cluster.
First is my super class -- this is the init method
DataHolder.m
- (id)initWithData:(NSData *)someData {
// look at the data
if([someData length] > 100) {
self = [[BigDataHolder alloc] initWithData:someData];
}
else {
self = [[SmallDataHolder alloc] initWithData:someData];
}
return self;
}
IE we chose the subclass based on the data... seems simple enough
Now onto the subclass's init methods
BigDataHolder.m // basically same for SmallDataHolder
- (id)initWithData:(NSData *)someData {
if(self = [super initWithData:someData]) {
// do some initialization here, etc
}
return self;
}
Anyway, I think you can see the problem here. This is going to go
into an infinite loop. What's the solution? Should I skip the call to
super and just call super super's init? Should I class sniff in my
DataHolder init? Is there some simple way out of this?
Class clusters seem cool but the documentation on how to actually
implement them has been a little off so far.
Thanks in advance.
-Steve
_______________________________________________
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