Comment puis-je itérer un appel de méthode par exemple.Objectif C Méthode Iterate Appelez
[self revertBox1];
[self revertBox2];
[self revertBox3];
[self revertBox4];
[self revertBox5];
// They are as many as 20.
example1 * xmp = [[example1 alloc] initWithNibName:@"example1" bundle:nil];
// How can I iterate the class instantiation example1, example2, example3
// If I use this method..
NSString *classNameStr = [NSString stringWithFormat:@"example%d", i];
Class cls = NSClassFromString(classNameStr);
cls *obj = [[[cls alloc] initWithNibName:classNameStr bundle:nil];
//I receive an error [ Use of undeclared identifier 'obj' ]
intelligente, mais user797819 vraiment juste Besoins de re-factoriser un peu son code et ses déclarations d'origine. –
@Coleman Stavish, Oui. Il devrait. – EmptyStack
---- NSString * classNameStr = [NSString stringWithFormat: @ "exemple% d", i]; ---- Classe cls = NSClassFromString (classNameStr); ---- cls * obj = [[[cls alloc] initNithNibName: classNameStr bundle: nil]; // Utilisation de l'identificateur non déclaré 'obj' –