//: Playground - noun: a place where people can play
importUIKit
funcformatString1(format:String,_args:CVarArgType...) {
formatString1_inner(format,getVaList(args))
}
// NSString format
funcformatString1_inner(format:String,_args:CVaListPointer) {
letstring =NSString(format: format, arguments: args)
print(string)
}
funcformatString2(format:String,_args:CVarArgType...) {
formatString2_inner(format, args);
}
// String format
funcformatString2_inner(format:String,_args:[CVarArgType]) {
letstring =String(format: format, arguments: args)
print(string)
}
formatString1("formatString1%d",1)
formatString2("formatString2%d",2)
网友评论