Swift and Objective-C
NS_REFINED_FOR_SWIFT
NS_REFINED_FOR_SWIFT
is a macro that helps you write “swifty” API for objective-c code.
In the header file, you tag the method declaration with this macro, and in a swift extension, you write a swift implementation that uses it. This method prepends two underscores (myMethod:whatever:
-> __myMethod(_: whatever:)
) to most methods, though in the case of initializers, it appends to the first argument label.
NS_SWIFT_NAME
NS_SWIFT_NAME
is a macro that lets you specify the swift name for an objective-c method.
In the header file, you tag the method declaration with this macro, giving it the swift method name as it’s argument, e.g.: -setFoo:(Foo *)foo NS_SWIFT_NAME(set(foo:));
Last updated: 2019-07-17 22:25:51 -0700