You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ObjectiveKit provides a Swift friendly API for a set of powerful Objective C runtime functions.
Usage
To use ObjectiveKit:
Import ObjectiveKit at the top of your Swift file:
import ObjectiveKit
The next step is to create an ObjectiveClass object typed for the class you want to modify or introspect:
letviewClass=ObjectiveClass<UIView>()
If using ObjectiveKit on a custom Swift class, make sure that it inherits at some point from NSObject and that it is exposed to the Objective C runtime using the @objc flag.
Introspection
You can learn more about classes at runtime with these handy introspection methods:
letmapViewClass=ObjectiveClass<MKMapView>()letivars= mapViewClass.ivars // An array of ivars.
letselectors= mapViewClass.selectors // An array of selectors.
letproperties= mapViewClass.properties // An array of properties.
letprotocols= mapViewClass.protocols // An array of protocols.
Modifying classes at runtime
Add a pre-existing selector from another class to your ObjectiveClass: