Re: Constructing class names dynamically

2009-01-15 Thread Greg Parker
On Jan 15, 2009, at 10:27 AM, Mohan Parthasarathy wrote: I have tried this to make sure that the class is loaded, but not working: [[NSBundle mainBundle] classNamed:clsName]; [self loadBundleForClass:clsName]; Class cls = NSClassFromString(clsName); I still get nil.. What am i missing ? You

Re: Constructing class names dynamically

2009-01-15 Thread Mohan Parthasarathy
Hi, Thanks a bunch.. It really helped me to debug the problem. -mohan On Thu, Jan 15, 2009 at 10:48 AM, Andy Lee wrote: > Unless you're explicitly loading in bundles or plugins, I wouldn't think > you need to force the class to be loaded. I just tested a call to > NSClassFromString(nameOfTes

Re: Constructing class names dynamically

2009-01-15 Thread Mohan Parthasarathy
Hi, I have tried this to make sure that the class is loaded, but not working: [[NSBundle mainBundle] classNamed:clsName]; [self loadBundleForClass:clsName]; Class cls = NSClassFromString(clsName); I still get nil.. What am i missing ? thanks mohan On Thu, Jan 15, 2009 at 9:17 AM, Mohan Part

Re: Constructing class names dynamically

2009-01-15 Thread Andy Lee
Unless you're explicitly loading in bundles or plugins, I wouldn't think you need to force the class to be loaded. I just tested a call to NSClassFromString(nameOfTestClass) as the first line of my main() function and it worked. In situations like this I try to question my most petty assum

Re: Constructing class names dynamically

2009-01-15 Thread Mohan Parthasarathy
Both of the methods return nil and as per the document it says "Class is not loaded". Is there a compile time option to load the classes or only way to do it as at runtime.. thanks mohan On Wed, Jan 14, 2009 at 6:46 AM, Adam Venturella wrote: > The output is the same, but there is also: > #impo

Re: Constructing class names dynamically

2009-01-14 Thread Adam Venturella
The output is the same, but there is also: #import objc_getClass([myString UTF8String]); I am going to guess that NSClassFromString(myString) is probably using objc_getClass(), maybe not. I didn't know NSClassFromString existed though, so I am switching to that instead of using the runtime.h fun

Re: Constructing class names dynamically

2009-01-13 Thread Mohan Parthasarathy
On Tue, Jan 13, 2009 at 8:06 PM, Ken Thomases wrote: > On Jan 13, 2009, at 3:33 PM, Jean-Daniel Dupas wrote: > > he is just talking about class name, not class. >> >> NSClassFromString() is probably what you're looking for. >> >> NSMutableString *clsName = derive class name from the entry. >> >>

Re: Constructing class names dynamically

2009-01-13 Thread Ken Thomases
On Jan 13, 2009, at 3:33 PM, Jean-Daniel Dupas wrote: he is just talking about class name, not class. NSClassFromString() is probably what you're looking for. NSMutableString *clsName = derive class name from the entry. Class cls = NSClassFromString(clsName); id instance = [[cls alloc] init]

Re: Constructing class names dynamically

2009-01-13 Thread Mohan Parthasarathy
thanks, this is exactly what i was looking for.. thanks mohan On Tue, Jan 13, 2009 at 1:41 PM, Bill Bumgarner wrote: > On Jan 13, 2009, at 1:33 PM, Jean-Daniel Dupas wrote: > >> he is just talking about class name, not class. >> >> NSClassFromString() is probably what you're looking for. >> >>

Re: Constructing class names dynamically

2009-01-13 Thread Bill Bumgarner
On Jan 13, 2009, at 1:33 PM, Jean-Daniel Dupas wrote: he is just talking about class name, not class. NSClassFromString() is probably what you're looking for. NSMutableString *clsName = derive class name from the entry. Class cls = NSClassFromString(clsName); id instance = [[cls alloc] init];

Re: Constructing class names dynamically

2009-01-13 Thread Jean-Daniel Dupas
Le 13 janv. 09 à 22:29, Bill Bumgarner a écrit : On Jan 13, 2009, at 1:18 PM, Mohan Parthasarathy wrote: Does this make sense ? Yes. Or this is a bad idea ? Yes. Generally, anyway, it is indicative of bad design when your code seems to require dynamic generation of classes. he is

Re: Constructing class names dynamically

2009-01-13 Thread Bill Bumgarner
On Jan 13, 2009, at 1:18 PM, Mohan Parthasarathy wrote: Does this make sense ? Yes. Or this is a bad idea ? Yes. Generally, anyway, it is indicative of bad design when your code seems to require dynamic generation of classes. Not to say that there aren't specific cases where it is warr

Constructing class names dynamically

2009-01-13 Thread Mohan Parthasarathy
Hi, Sorry for the bad subject name. I found no other way to explain this. What i need is a way to generate a class name dynamically. For example, the user selects an entry in the Table (assume just one column) and each entry is handled by a separate class. Obviously, i can have a dictionary which