ProductsDataSource

public class ProductsDataSource

A ProductsDataSource is responsible for providing actual products data, given LocalProductsDataSource and StoreProductsDataSource objects.

  • Initializes a new products data source.

    Declaration

    Swift

    public init(localProducts: LocalProductsDataSource, storeProducts: StoreProductsDataSource)

    Parameters

    localProducts

    LocalProductsDataSource object.

    storeProducts

    StoreProductsDataSource object.

    Return Value

    A new ProductsDataSource instance.

  • The number of products.

    Declaration

    Swift

    public var numProducts: Int
  • Localized name for product at index. If products received from the store, returns localized name received from the store, otherwise returns name of corresponding local product, localized with NSLocalizedString macro.

    Declaration

    Swift

    public func localizedNameForProductAtIndex(_ index: Int) -> String

    Parameters

    index

    An index of product in the data source.

    Return Value

    Localized name for product on specified index.

  • Localized description for product at index. If products received from the store, returns localized description received from the store, otherwise returns description of corresponding local product, localized with NSLocalizedString macro.

    Declaration

    Swift

    public func localizedDescriptionForProductAtIndex(_ index: Int) -> String

    Parameters

    index

    An index of product in the data source.

    Return Value

    Localized description for product on specified index.

  • Localized price for product at index. If products received from the store, returns localized price received from the store, otherwise returns nil.

    Declaration

    Swift

    public func localizedPriceForProductAtIndex(_ index: Int) -> String?

    Parameters

    index

    An index of product in the data source.

    Return Value

    Localized price for product on specified index.

  • Declaration

    Swift

    public func identifierForProductAtIndex(_ index: Int) -> String

    Parameters

    index

    An index of product in the data source.

    Return Value

    Identifier for product on specified index.