• 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: Basic runtime function usage - objc_getClass
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Basic runtime function usage - objc_getClass


  • Subject: Re: Basic runtime function usage - objc_getClass
  • From: Damien Bobillot <email@hidden>
  • Date: Wed, 23 Nov 2005 19:43:09 +0100


Sherm Pendley wrote :

On Nov 23, 2005, at 11:11 AM, Francis Derive wrote:

I beg the pardon of those who recently helped me, but now failed on this :

id myPointerToClass = (Class *) objc_getClass("MYobject");

This would be easier (see below) if you typed myPointerToClass differently. "id" is a typedef for "objc_object*", but in fact it can be either that or "objc_class*", either of which can be a message target. objc_getClass() returns a Class (not a Class*), but it's declared as id so that you can easily send messages to it. (Class, btw, is a typedef for objc_class*)


Class myPointerToClass = (Class) objc_getClass("MYobject");

Just a remark. The dedicated Cocoa function to do this is NSClassFromString :
Class MyClass = NSClassFromString(@"MyClass");


However, you may also use objc_getClass, but it's not the Cocoa way to do it.

--
Damien Bobillot

_______________________________________________
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


  • Follow-Ups:
    • Re: Basic runtime function usage - objc_getClass
      • From: Sherm Pendley <email@hidden>
References: 
 >Basic runtime function usage - objc_getClass (From: Francis Derive <email@hidden>)
 >Re: Basic runtime function usage - objc_getClass (From: Sherm Pendley <email@hidden>)

  • Prev by Date: Re: CIImage slower than NSImage?
  • Next by Date: Re: Basic runtime function usage - objc_getClass
  • Previous by thread: Re: Basic runtime function usage - objc_getClass
  • Next by thread: Re: Basic runtime function usage - objc_getClass
  • Index(es):
    • Date
    • Thread