View

extension View
  • A public global function that formats and prints a message to the console corresponding to data stored as JSON for a given print number and behaves as an analogue overload of the Swift print(_:separator:terminator:) function.

    This function behaves exactly as the Clarity global scope print overload with the same parameters other than to return an empty View that allows it to be used within the body variable of a View Because it will always be called within a View it is still possible to call it without having to specify a defining type – in the same manner as the Swift print(_:separator:terminator:) function.

    Declaration

    Swift

    public func print(_ printNumber: Int,
                      functionName: String? = nil,
                      settings: SettingsManagerService? = nil) -> some View

    Parameters

    printNumber

    An Int that acts as a unique number used as a key to access a specific associated message from a dictionary containing all message data.

    functionName

    An optional parameter for a #function macro argument. If this parameter is included Clarity formats and prints the log as a function call node for the function that contains printNumber.

    settings

    An optional parameter for a dynamic SettingsManagerService instance. The SettingsManagerService instance can have its properties set programmatically to a variety of values. This enables more convenient and dynamic evaluation of a wider range of unit tests in a test target than is possible when using the JSON access mechanism.

    Return Value

    An empty View that allows the function to conform to the View protocol and be used within the body var of a View instance.

  • A public global function that formats and prints a message to the console corresponding to data stored as JSON for a given print number and behaves as an analogue overload of the Swift print(_:separator:terminator:) function.

    This function behaves exactly as the Clarity global scope print overload with the same parameters other than to return an empty View that allows it to be used within the body variable of a View Because it will always be called within a View it is still possible to call it without having to specify a defining type – in the same manner as the Swift print(_:separator:terminator:) function.

    Declaration

    Swift

    public func print(_ printNumber: Int,
                      values: Any? = nil,
                      settings: SettingsManagerService? = nil) -> some View

    Parameters

    printNumber

    An Int that acts as a unique number used as a key to access a specific associated message from a dictionary containing all message data.

    values

    An optional parameter for the inclusion of variable values to be printed as part of the message. If this parameter is included Clarity formats and prints the log as a value report node. The parameter can be a single value of any type, a Collection of any type or an instance conforming to the Error protocol.

    settings

    An optional parameter for a dynamic SettingsManagerService instance. The SettingsManagerService instance can have its properties set programmatically to a variety of values. This enables more convenient and dynamic evaluation of a wider range of unit tests in a test target than is possible when using the JSON access mechanism.

    Return Value

    An empty View that allows the function to conform to the View protocol and be used within the body var of a View instance.