Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

print() vs debugPrint() in swift

This might be a simple question but because of clear understanding between print() and debug() print in swift I am unable to understand where to use each one.

like image 541
Rajan Twanabashu Avatar asked Jan 24 '17 11:01

Rajan Twanabashu


People also ask

What does print mean in Swift?

You use print() in Swift to print a string of text to the Console, or standard output. It's super useful for debugging and finding out what's going on in your code.

How do I print a log in Swift?

SwiftLog - A Logging API package for Swift The usage is really straightforward. First you have to import the Logging framework, then you create a logger and you use that logger instance to print out various log messages. import Logging let logger = Logger(label: "app-identifier") logger.info("Hello World!")

How do I print in debug only in Swift?

Swift Print() Only in Debug Mode? Basically print() function is used to write text to the Xcode debug console in Swift. It helps to debug the code. The print() function is actually variadic, so you can pass it more than one parameter and it will print them all.

What is debug print?

Debug. Print is telling VBA to print that information in the Immediate Window. This can be useful when you want to see the value of a variable in a certain line of your code, without having to store the variable somewhere in the workbook or show it in a message box.


1 Answers

You use debugPrint when you want more information about what is being printed to the console. The additional information is usually useful for debugging.

print() - Writes the textual representations of the given items into the standard output.

debugPrint() - Writes the textual representations of the given items most suitable for debugging into the standard output.

Basically debugPrint adds additional information that is useful for debugging like type information etc.

An example:

print(1...5) // Prints "1...5"   debugPrint(1...5) // Prints "CountableClosedRange(1...5)" 
like image 179
Iggy Avatar answered Sep 21 '22 14:09

Iggy