• 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: Is it possible to dynamically create a class?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is it possible to dynamically create a class?


  • Subject: Re: Is it possible to dynamically create a class?
  • From: Oleg Kibirev <email@hidden>
  • Date: Fri, 17 Aug 2007 16:38:09 -0700

There are a few possible approaches:

1. Just execute your getters and setters in -forwardInvocation: of a preset class that stores names, types and values of it's "instance variables" in a dictionary. One difficulty you may encounter is that you need to return a valid -methodSignatureForSelector: If all possible types of instance variables are known at compile time, you can just include some dummy methods to be used as templates. If not, NSMethodSignature has an undocumented method to create a signature from an encoded string.

2. Since all you need is get and set instance variables, why don't you just use an NSMutableDictionary in the first place?

3. If you are in a position to ask users to install developer tools or else are able to bundle gcc with your app, you can just generate source code, compile it into a bundle and load that bundle programatically.

Oleg

On Aug 17, 2007, at 3:00 PM, Bob Ueland wrote:

Is it possible to dynamically create a class?

Suppose for instance that I have an object called SimpleClassCreator that has a method called
createClass which accepts parameters giving the name of the class and the name and type of instance variables. The createclass would then dynamically (during runtime) create a class-object with the given name and the given instance variables, and would create one setter method and one getter method for each given instance variable. Is that possible?


Thanks Bob




______________________________________________________________________ ______________
Luggage? GPS? Comic books?
Check out fitting gifts for grads at Yahoo! Search
http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz
_______________________________________________


Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
40oracle.com


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Is it possible to dynamically create a class? (From: Bob Ueland <email@hidden>)

  • Prev by Date: Re: Is it possible to dynamically create a class?
  • Next by Date: keycode <-> character
  • Previous by thread: Re: Is it possible to dynamically create a class?
  • Next by thread: Re: Is it possible to dynamically create a class?
  • Index(es):
    • Date
    • Thread