• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: objc_getClassList, pointers, and NSArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Prev by Date: Re: NIAuthentificationButton
  • Next by Date: Re: How to stop initial window ?
  • Previous by thread: Re: objc_getClassList, pointers, and NSArray
  • Next by thread: document icons in Cocoa like Image Capture
  • Index(es):
    • Date
    • Thread