0

I need some help here.

So I have this class. Books.h

I want to do this

int a = 1
NSString *myName = [NSString stringWithFormat:@"Name%i", a];
Books *myName = [[Books alloc]init];

// some code here

a++;

// Re do the whole thing over 

What i dont get is how to pass my custom variable name to Books. It will end up being a dictionary so i guess i cant use the same name all the time. I will be adding values on button click.

Or can i use that?

Dmitri K.
  • 197
  • 1
  • 13
  • Sorry i meant to say it will be an NSMutableArray. So i need to add the variable and then put this all in table view. – Dmitri K. Nov 12 '15 at 21:15
  • Your pseudocode needs to be fixed to make the question comprehensible. Why are both assignments into `myName`? How is `myName` being used? – bhaller Nov 12 '15 at 23:39
  • Sorry it was an example, I admit not the best one. The logic here is that every time i will generate a String say Name1, Name2, Name3. After which I want this name to be passed to Books class. So on first go it will be Books *Name1 = [[Books alloc]init]; on second it will be Books *Name2 = [[Books alloc]init]; etc. I will get the number incremented based on number of entries in the dictionary later on, so i just want the name i use to start a class methods to always be different, but not sure if i can do it. – Dmitri K. Nov 13 '15 at 08:39
  • OK, yep, looks like a dup, then. – bhaller Nov 13 '15 at 13:32

0 Answers0