我無法理解Objective-C中多個參數的語法。我見過this question,但答案並沒有幫助我(還)。如何使用va_args傳遞參數(可變參數,省略號)
這裏是我的代碼(其實我會想最終傳遞給NSString的stringWithFormat,但得到的NSLog的工作就足夠好了):
- (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);
}
的參數(或參數)來通過,但它有一些奇怪的值(輸出是blah blah 1606412704
)。我應該如何傳遞通過...
進入的值?
相關,但不完全重複的:http://stackoverflow.com/questions/2345196 – 2010-06-29 19:40:44