Re: objc_getClassList, pointers, and NSArray
Re: objc_getClassList, pointers, and NSArray
- Subject: Re: objc_getClassList, pointers, and NSArray
- From: Rob Rix <email@hidden>
- Date: Mon, 9 Jul 2001 15:34:14 -0400
Careful here. There's a "leak" at least (over-retain). The -retain
message is unnecessary since the NSArray will do that, and you're likely
to forget elsewhere to send -release to every contained object in that
array before releasing the array.
The ObjC classes are objects, as well, so you can put them directly in
the NSArray.
NSMutableArray classes = [[NSMutableArray alloc] init];
for (i = 0; i < numClasses; i++) {
[classes addObject:classes[i]];
}
Using the string name of the class, though, is a legitimate way to go
about saving this information, and then you use NSClassFromString() later
to "convert" back to the class object.
I think I'll end up storing the strings, to stay consistent within the API
I'm working on.
Thanks!
There are a few subtle situations in which you will actually get
different results over time (during execution of the program) depending
on which technique you use. If somebody pipes up wanting to know more
about this, perhaps some of the advanced developers on the list will
explain further.
Err...well, why not? This is something I'd be interested in knowing.
Oh, and by the way, to David, thanks for the help, and great e-mail
address :)
-- Rob
Flying is the sustained art of falling sideways without letting physics
catch on to what you're up to.