问题描述:

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.

网友答案:

Using print() is a regular way to visualy see what you are creating. It does not show 'irrelevant' information that is not neccesary to represent the printed variable.

e.g.

print("test")
// prints: test

Using debugPrint() however adds the inferred type to the output.

e.g.

debugPrint("test")
// prints: "test"

Note how it adds the quotation marks to let you know it is a string.

Erica Sadun has created a perfect example of how these two functions differ: Swift: Logging

相关阅读:
Top