I am working on something similar to a canvas, users can add drag labels onto a view, resize them and whatnot.
My Question for you is: What do you think is the best way to load these labels programatically?
This may sound foolish at first but I do not know how many labels there will be, so I do not want to hardcode n Labels and find the user uses n-200, if you see what I mean? I am aware that it is simplistic to do:
UILabel *myLabel = [[UILabel alloc] init];
but then I have one label called myLabel, is there any way to programatically name these variables? As we all know we cannot have more than variable with the same name.
An example may help:
User drags on 2 labels, saves this view. I come to load it later, programatically. What is the best way to create and name these 2 labels, having no prior knowledge of how many labels there were (i.e. cannot be hardcoded).
I am aware this is a shoddy explanation but, if someone can wade through my crap and see the question, please add your 2 cents!
You could assign a numeric value to the “tag” property of the UILabel if you’re trying to somehow have an identifier associated with them. (If I’m understanding your question correctly)
Or if the question is how to load them, you could use NSMutableArray and then just keep looping through your saved labels, create them, assign the new UILabel reference to a new entry in the array.
Again, not 100% sure of what the issue is that you’re facing though maybe this can help.