Obj-C: Creating an object with a String name

Posted by FnGreg7 on Stack Overflow See other posts from Stack Overflow or by FnGreg7
Published on 2010-06-03T16:44:06Z Indexed on 2010/06/03 17:04 UTC
Read the original article Hit count: 150

Filed under:
|
|
|

Hey all. I know this sounds simple, but I can't find a way to do it. I have a method in Obj-C that takes in a NSString and then should create a new class with the String as its title.

-(DataModel *)createDataModel:(NSString *)dataModel_name {
        DataModel *[initWithString:dataModel_name] = [[DataModel alloc] init];
        }

I know I have some problems in this. For starters, I don't know how to define a return on an object whose name could change. Second, I know this doesn't compile considering the initWithString method is wrong. I just don't know what to do or what method to use so that I can create this DataModel object with the specified name...

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c