我正在爲內部使用appendFormat:
的NSMutableString編寫一個類別。具有未知參數個數的Objective-c方法
@interface NSMutableString (Additions)
- (void)appendFormatWithLine:(NSString *)format, ...;
@end
@implementation NSMutableString (Additions)
- (void)appendFormatWithLine:(NSString *)format, ... {
va_list args;
va_start(args, format);
// **calling [self appendFormat] gives a 'EXC_BAD_ACCESS'**
[self appendFormat:format, args];
[self appendString:@"\r\n"];
va_end(args);
}
@end
我不知道如何使用va_list或va_start來調用NSMutableString:appendFormat
。如何才能做到這一點?
這這個問題的答案可能是有用的:HTTP: //stackoverflow.com/questions/2137752/objective-c-va-list-and-selectors –