AbstractCollectionDataSource

@available(*, deprecated, message: "Migrate to `CollectionDataSource` https://github.com/stanwood/SourceModel_iOS")
open class AbstractCollectionDataSource : NSObject, UICollectionViewDataSource, CollectionDataSource, DataSourceType

The AbstractCollectionDataSource conforms to the CollectionDataSource protocol and implements AbstractCollectionDataSource.numberOfSections(in:) and AbstractCollectionDataSource.collectionView(_:numberOfItemsInSection:). It midiates the application data model DataType and Type for the UICollectionView.

It is requried to subclass AbstractCollectionDataSource and override AbstractCollectionDataSource.collectionView(_:cellForItemAt:)

Example: DataSource and Delegate design
let items = [Element(id: "1"), Element(id: "2")]
self.objects = Stanwood.Elements<Element>(items: items)

self.dataSource = ElementDataSource(dataObject: objects)
self.delegate = ElementDelegate(dataObject: objects)

self.collectionView.dataSource = self.dataSource
self.collectionView.delegate = self.delegate

See also

AbstractCollectionDelegate

Objects

DataType

Type

  • dataObject, a collection of types

    Declaration

    Swift

    public internal(set) var dataType: DataType? {
      get
      }
  • A single type object to present

    Declaration

    Swift

    public internal(set) var type: Type? {
      get
      }
  • Initialise with a collection of types

    See also

    DataType

    Declaration

    Swift

    public init(dataType: DataType?, delegate: AnyObject? = nil)

    Parameters

    dataObject

    dataObject

    delegate

    optional AnyObject delegate

  • Initialise with a a single type object.

    See also

    Type

    Declaration

    Swift

    public init(type: Type, delegate: AnyObject? = nil)

    Parameters

    dataType

    DataType

  • update current dataSource with dataObject. sdasdfasdf

    Note: If data type is a class, it is not reqruied to update the type. svasdf asdasd Hi:

    See also

    Type

    Declaration

    Swift

    open func update(with dataType: DataType?)

    Parameters

    dataType

    type

  • update current dataSource with type.

    Note: If data type is a class, it is not reqruied to update the type.

    See also

    DataType

    Declaration

    Swift

    open func update(with type: Type?)

    Parameters

    type

    Type