• 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: Creating a Class Instance By Name
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating a Class Instance By Name


  • Subject: Re: Creating a Class Instance By Name
  • From: Evan Schoenberg <email@hidden>
  • Date: Tue, 7 Dec 2004 23:29:13 -0600

You probably want to do something like this:

Class myClassNameClass = NSClassFromString("MyClassName");
myClassNameClass	*instance = [[myClassNameClass alloc] init];

-Evan

On Dec 7, 2004, at 11:14 PM, Seth Willits wrote:

I need to create a class instance based on its name (as NSDocumentController does from the Info.plist in every document-based application) but I can't figure out the exact steps to do so. I'm doing:


Class class = objc_getClass("MyClassName"); id instance = class_createInstance(class, 0);

But I always get "warning: initialization makes pointer from integer without a cast" on the second line.


Reference: id objc_getClass(const char *aClassName); id class_createInstance(Class theClass, unsigned additionalByteCount);



-- Seth

_______________________________________________
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


_______________________________________________ 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
References: 
 >Creating a Class Instance By Name (From: Seth Willits <email@hidden>)

  • Prev by Date: Re: Creating a Class Instance By Name
  • Next by Date: re:[newbie] Cyclic #import
  • Previous by thread: Re: Creating a Class Instance By Name
  • Next by thread: Re: Creating a Class Instance By Name
  • Index(es):
    • Date
    • Thread