typedef __builtin_va_list __darwin_va_list;
typedef __builtin_va_list va_list;
@interface NSString
@end
va_list argList;
@interface NSString (NSStringExtensionMethods)
- (NSString *)stringByAppendingFormat:(NSString *)format, ... __attribute__((format(__NSString__, 1, 2)));
- (instancetype)initWithFormat:(NSString *)format, ... __attribute__((format(__NSString__, 1, 2))); - (instancetype)initWithFormat:(NSString *)format arguments:(va_list)argList __attribute__((format(__NSString__, 1, 0)));
- (instancetype)initWithFormat:(NSString *)format locale:(id)locale, ... __attribute__((format(__NSString__, 1, 3)));
- (instancetype)initWithFormat:(NSString *)format locale:(id)locale arguments:(va_list)argList __attribute__((format(__NSString__, 1, 0)));
+ (instancetype)stringWithFormat:(NSString *)format, ... __attribute__((format(__NSString__, 1, 2))); + (instancetype)localizedStringWithFormat:(NSString *)format, ... __attribute__((format(__NSString__, 1, 2))); - (void)MyRandomMethod:(NSString *)format locale:(id)locale arguments:(va_list)argList __attribute__((format(__NSString__, 1, 0))); @end
@interface NSMutableString : NSString
@end
@interface NSMutableString (NSMutableStringExtensionMethods)
- (void)appendFormat:(NSString *)format, ... __attribute__((format(__NSString__, 1, 2)));
@end
NSString *ns(NSString *pns) {
[pns initWithFormat: @"Number %d length %c name %s", 1, 'a', "something"]; [NSString localizedStringWithFormat : @"Hello%s", " There"]; [pns initWithFormat : @"Hello%s %d %d", "Hello", 1, 2]; [pns MyRandomMethod : @"Hello%s %d %d" locale:0 arguments: argList]; return [NSString stringWithFormat : @"Hello%s", " There"]; }
typedef const struct __CFString * CFStringRef;
typedef struct __CFString * CFMutableStringRef;
typedef const struct __CFAllocator * CFAllocatorRef;
typedef const struct __CFDictionary * CFDictionaryRef;
extern
CFStringRef CFStringCreateWithFormat(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, ...) __attribute__((format(CFString, 3, 4)));
extern
CFStringRef CFStringCreateWithFormatAndArguments(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, va_list arguments) __attribute__((format(CFString, 3, 0)));
extern
void CFStringAppendFormat(CFMutableStringRef theString, CFDictionaryRef formatOptions, CFStringRef format, ...) __attribute__((format(CFString, 3, 4)));
extern
void CFStringAppendFormatAndArguments(CFMutableStringRef theString, CFDictionaryRef formatOptions, CFStringRef format, va_list arguments) __attribute__((format(CFString, 3, 0)));
void Test1(va_list argList) {
CFAllocatorRef alloc;
CFStringCreateWithFormatAndArguments (alloc, 0, (CFStringRef)@"%s\n", argList); CFStringAppendFormatAndArguments ((CFMutableStringRef)@"AAAA", 0, (CFStringRef)"Hello %s there %d\n", argList); CFStringCreateWithFormatAndArguments (alloc, 0, (CFStringRef)@"%c\n", argList);
CFStringAppendFormatAndArguments ((CFMutableStringRef)@"AAAA", 0, (CFStringRef)"%d\n", argList);
}
extern void MyNSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2))); extern void MyCFStringCreateWithFormat(CFStringRef format, ...) __attribute__((format(__CFString__, 1, 2))); extern void XMyNSLog(int, NSString *format, ...) __attribute__((format(__NSString__, 2, 3)));
void Test2(void) {
MyNSLog(@"%s\n", "Hello");
MyCFStringCreateWithFormat((CFStringRef)@"%s", "Hello"); XMyNSLog(4, @"%s\n", "Hello"); }