Skip to content

Instantly share code, notes, and snippets.

@ytyubox
Last active October 5, 2020 05:50
Show Gist options
  • Save ytyubox/80535e8a829382acc2c861e756155db8 to your computer and use it in GitHub Desktop.
Save ytyubox/80535e8a829382acc2c861e756155db8 to your computer and use it in GitHub Desktop.
A useful print helping debugging.
func dprint(_ objects:Any..., separator: String = " ", terminator: String = "\n",file:String = #file,line:Int = #line, function:String = #function){
#if DEBUG
print((file).split(separator: "/").last!,line.description + ":",function)
print("🦑 Debug info: \n\t", terminator: "")
for i in objects{
print(i, separator: "", terminator: separator)
}
print(terminator)
#endif
}

Usage

dprint(<#any thing you want to print#>)


More custom printing

Create a Code Snippet, to avoid touch file, line and funcion. Maybe the xcode system will do this for you, maybe not.

dprint(<#T##items: Any...##Any#>, separator: <#T##String#>, terminator: <#T##String#>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment