I'm developing an iPad App and need some help.
Through a button within my App I want to create one object at a time. So every time the button is touched one object should be created.
The problem I have is: I want to assign each object a dynamic name to identify this object. This would be something like: form0, form1, form2, ..., formN.
This Name corresponds to an instance variable within every object. So the form1 instance has a number attribute which is 1.
But how do I assign this form1, form2, etc. to a new instance?
I tried to initialize a new instance with the return of a method which creates the formX-String:
-(NSString*)giveMeName{
NSString* simpleName = @"form";
NSString* newName = [simpleName stringByAppendingString:[NSString stringWithFormat:@"%d", questionCounter]];
return newName;
}
where questionCounter is a variable which holds the int identifier for both formX and the instance number attribute.
But when I want to initialize a new instance with this function as name it's not working:
TSForm* [self giveMeName] = [[TSForm alloc] initWithInt:questionCounter headline:headlineText intro:introText];
Obviously I got something wrong with the inner working of Objective-C. Please help me out.