I have following function:
func myNSLog(_ givenFormat: String, _ args: CVarArg..., _ function:String = #function) {
let format = \"\\(function): \\(g
Similar as in C, you cannot pass a variable argument list directly
to another function. You have to create a CVaListPointer
(the Swift
equivalent of va_list
) and pass that to the NSLogv
variant:
func myNSLog(_ givenFormat: String, _ args: CVarArg..., _ function:String = #function) {
let format = "\(function): \(givenFormat)"
withVaList(args) { NSLogv(format, $0) }
}
(Swift 3 code.)