Posts

Showing posts from February 19, 2019

How to swizzle Swift.print(items:separator:terminator)

Image
2 0 I am looking for ways to swizzle Swift.print function. Overriding it is not an option, as it may get bypasses if you use Swift.print(:) The selector does not recognise the identifier: @objc class func printSwizzle() { guard let instance = class_getInstanceMethod(self, #selector(print(separator:terminator:))), let swizzleInstance = class_getInstanceMethod(self, #selector(swizzlePrint(separator:terminator:))) else { return } method_exchangeImplementations(instance, swizzleInstance) } Is that even possible? As swizzling is an obj-c runtime feature. ios swift method-swizzling share | improve this question edited Jan 1 at 8:42