AndyIbanez / andyibanez-com

Static website.
1 stars 0 forks source link

posts/swift-print-in-depth/ #53

Open utterances-bot opened 7 months ago

utterances-bot commented 7 months ago

Swift's print in Depth • Andy Ibanez

https://www.andyibanez.com/posts/swift-print-in-depth/

GanZhiXiong commented 7 months ago

The article is well written, 👍🏻! Is it possible to intercept print without to parameter? Can it be achieved through method swizzling?

baalexxx commented 7 months ago

I found how to intercept print without to parameter: use: _playgroundPrintHook https://oleb.net/blog/2016/09/playground-print-hook/

GanZhiXiong commented 7 months ago

I found that rewriting the print function can intercept all prints without using _playgroundPrintHook

public func print(_ items: Any..., separator: String = " ", terminator: String = "\n") {
    Swift.print(items, separator: separator, terminator: terminator)
}