I'm creating an application, in which i used an NSMutableArray
to stock some objects. To do this, no problem in first look :
ArrayOfViews = [[NSMutableArray alloc] init];
[ArrayOfViews addObject:...];
But my object are UIViews, that i create. For example, I have a file named "Level1". How could I add an object from "Level1", like :
Level1 * level1view;
decalered in the same UIViewcontroller from my NSMuttableArray ?
Like a sort of :
for (i = 0, i < max, i++)
{
[ArrayOfViews addObject:[objectWithName:[NSString stringWithFormat:@"level%iview", i]]];
}
I don't know how could I wrote it with good encoding.
Second, to use the objects with a selector and parameters, how could i do ?
Because i tried :
NSString * futureSelector = [NSString stringWithFormat:@"Level%iappearswithTime:", number];
SEL s = NSSelectorFromString(futureSelector);
NSInvocation * invoc = [[NSInvocation alloc] init];
[invoc setSelector:s];
[invoc setArgument:&t atIndex:1];
[invoc setTarget:[ArrayOfViews objectAtIndex:number]];
[invoc invoke];
To replace this sort of code :
[level1view Level1appearswithTime:t];
where variable t is an NSTimeInterval
Thanks for your help !