Price

@objc(GFYPrice)
public class Price : NSObject, Encodable

Represents a positive monetary price value

  • The magnitude of the price to two decimal places

    Declaration

    Swift

    @objc
    public var amount: Decimal { get }
  • Creates a Price instance

    Returns nil if the provided amount cannot be represented (such as if it is negative).

    Declaration

    Swift

    @objc
    public init?(amount: Decimal)

    Parameters

    amount

    The magnitude of the price

  • Override for Hashable protocol implementation to hash based on numeric value

    Declaration

    Swift

    public override var hash: Int { get }
  • Returns a Boolean value that indicates whether the receiver and a given object are equal.

    Equality for Price objects is assessed by comparing its numeric components

    Declaration

    Swift

    public override func isEqual(_ object: Any?) -> Bool

    Parameters

    object

    The object to be compared to the receiver

    Return Value

    true if the receiver and object are equal, otherwise false

  • Encodes an instance of Price

    Declaration

    Swift

    public func encode(to encoder: Encoder) throws
  • Retrieves String representation of Price

    Declaration

    Swift

    public override var description: String { get }