• 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
objc_getClassList, pointers, and NSArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

objc_getClassList, pointers, and NSArray


  • Subject: objc_getClassList, pointers, and NSArray
  • From: Rob Rix <email@hidden>
  • Date: Mon, 9 Jul 2001 04:39:50 -0400

Hey, all.
I've used the sample code in /usr/include/objc/objc_runtime.h to get a list of classes. The sample code is as follows:

int numClasses = 0, newNumClasses = objc_getClassList(NULL, 0);
Class *classes = NULL;
while (numClasses < newNumClasses) {
numClasses = newNumClasses;
classes = realloc(classes, sizeof(Class) * numClasses);
newNumClasses = objc_getClassList(classes, numClasses);
}
// now, can use the classes list; if NULL, there are no classes
free(classes);

So, that's fine. It suits me perfectly.

Problem is, I want to put the classes into an NSArray (or subclass thereof)
for use elsewhere in my application. Unfortunately, I missed a great deal of the stuff about pointers in my C class due to illness, so I'm not entirely clear on procedure here.

I was thinking about pointer arithmetic, but I can't remember how to do that, nor can I remember how to be sure I don't overrun the classes buffer.

Pointers are arcane enough when you're just using objects, getting into buffers is really weird for me.

Anyhow, thanks in advance for any help you can provide on how to get the classes into an NSArray,

-- Rob

Murphy strikes again!


  • Follow-Ups:
    • Re: objc_getClassList, pointers, and NSArray
      • From: David Remahl <email@hidden>
  • Prev by Date: Re: Let's hope XP doesn't keep this "one-up" on OS X!
  • Next by Date: Re: objc_getClassList, pointers, and NSArray
  • Previous by thread: Re: Just starting out..... Please help
  • Next by thread: Re: objc_getClassList, pointers, and NSArray
  • Index(es):
    • Date
    • Thread