PTOverrides


@interface PTOverrides : NSObject

The PTOverrides class is used to register overridden subclasses of classes defined in the Tools library. Once a class conforming to the PTOverridable protocol has been “overridden”, whenever an instance of the original class would be created the subclass is used instead.

  • Adds an overridden subclass of a class conforming to the PTOverridable protocol.

    Note

    An exception is thrown if none of the subclass’s superclasses conform to the required PTOverridable protocol.

    Declaration

    Objective-C

    + (void)addOverriddenClass:(nonnull Class)subclass;

    Swift

    class func addOverriddenClass(_ subclass: AnyClass)

    Parameters

    subclass

    a subclass to use in place of its superclass

  • Override the given class with a subclass.

    Declaration

    Objective-C

    + (void)overrideClass:(nonnull Class)cls withClass:(nonnull Class)subclass;

    Swift

    class func overrideClass(_ cls: AnyClass, with subclass: AnyClass)

    Parameters

    cls

    the class to override, conforming to the PTOverridable protocol

    subclass

    the subclass to use in place of the cls

  • Returns the overridden subclass for the given class, if one has been registered.

    Declaration

    Objective-C

    + (nullable Class)overriddenClassForClass:(nonnull Class)cls;

    Swift

    class func overriddenClass(for cls: AnyClass) -> AnyClass?

    Parameters

    cls

    the original class

    Return Value

    the overridden subclass, or Nil if one has not been registered