Swift:
Виведення налагоджувальної інформації
How to: (Як це зробити:)
// Basic output
print("Hello, Ukraine!")
// Interpolating variables
var greeting = "Вітаю"
print("\(greeting), reader!")
// Printing multiple items
let apples = 5
let oranges = 3
print("Apples: \(apples), Oranges: \(oranges)")
// Sample Output:
// Hello, Ukraine!
// Вітаю, reader!
// Apples: 5, Oranges: 3
Deep Dive (Поглиблений Розбір)
Print debugging has been a developer’s quick tool since early programming. It’s simple yet effective, often helping catch culprits fast. While print statements are handy, use logging tools (like os_log
in iOS) when you need more control and options. Logging can filter messages, set importance levels, and work better for released apps. Swift also differentiates between print (stdout) and debugPrint (stderr), the latter being more detailed.
See Also (Дивіться також)
- Swift Documentation on print: https://developer.apple.com/documentation/swift/1541053-print
- Effective logging in Swift: https://www.swiftbysundell.com/articles/logging-in-swift/
- Apple’s Unified Logging System overview: https://developer.apple.com/documentation/os/logging