Re: creating classes on the fly ??
Re: creating classes on the fly ??
- Subject: Re: creating classes on the fly ??
- From: "Clark Cox" <email@hidden>
- Date: Thu, 4 Oct 2007 16:28:06 -0700
On 10/4/07, Karsten <email@hidden> wrote:
> Well i was wondering why one would want to create classes on the
> fly...i mean, there may be reasons for this,
The main reason that I can think of to do this is when making a bridge
of sorts between Cocoa and another language. For instance, I once did
just this when wrapping a C++ introspection framework to allow it to
be used with Cocoa bindings. When my bridge was connected to a C++
class registered with this framework, it would synthesize an
Objective-C class that had named accessor methods that would call
through to the appropriate C++ accessors on the wrapped object.
> but i don't think that
> storing data could be the reason to do this. Besides Cocoa i'm
> developing with Smalltalk a lot and there're it is no problem to
> create classes and to compile methods dynamically, but there're really
> not many reasons why you would want to do this. I created classes and
> methods on the fly in order to store information using a source code
> management system, but besides this reason i don't see much advantage
> against storing data in some model classes that are good enough to
> handle all the data you would want to store. I think code data may do
> a big deal in helping you out there.
>
> Another thing is that i don't know how you are going to debug the
> stuff that you are creating on the fly?! i mean... if you have the
> classes, and the methods (however you compile them at runtime in
> cocoa), how do you want to debug the execution of these methods?
Depending on how you construct the class, debugging them is not really
that different from debugging any other class. Most of the methods on
the classes in my bridge shared a few common method implementations
(i.e. one implementation for a getter that returns an int, another for
a getter that returns an object, another for a setter that takes a
float, etc.). The debugger had no problem stopping at breakpoints
placed within those implementations.
--
Clark S. Cox III
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