Je ne peux pas comprendre la syntaxe de plusieurs arguments dans Objective-C. J'ai vu this question, mais la réponse ne m'a pas (encore) aidé.Comment utiliser va_args pour passer des arguments (paramètres variadiques, ellipses)
Voici mon code (en fait, je veux éventuellement passer à NSString stringWithFormat, mais obtenir un NSLog travailler serait assez bon pour l'instant):
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
[self log:@"blah blah %d", 32];
}
- (void)log:(NSString *)text, ... {
va_list args;
va_start(args, text);
NSLog(text, args);
}
L'argument (ou un argument) vient par , mais il a une valeur bizarre (la sortie est blah blah 1606412704
). Comment dois-je transmettre les valeurs entrées via ...
?
Relatif à, mais pas tout à fait un doublon de: http://stackoverflow.com/questions/2345196 –