Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

Releases: 3lvis/DATASource

DATASource — 6.1.4

13 Dec 11:22
Compare
Choose a tag to compare
  • Fix safeguard and improve generated title to not be optional

DATASource — 6.1.3

13 Dec 10:13
Compare
Choose a tag to compare
  • Add guard for index out of bounds when accessing cached sections

DATASource — 6.1.2

06 Nov 12:58
Compare
Choose a tag to compare

Xcode 8.1 release

DATASource — 6.1.1

17 Oct 20:23
Compare
Choose a tag to compare

Fixes an issue with the title in the following delegate call, after the Swift 3 migration it returned an array, not it just returns Any?

extension MyController: DATASourceDelegate {
    func dataSource(_ dataSource: DATASource, collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: IndexPath, withTitle title: Any?) -> UICollectionReusableView? {
        let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindSectionHeader, withReuseIdentifier: TimelineHeaderView.identifier, for: indexPath) as! TimelineHeaderView
        if let title = title as? Date {
            headerView.title = self.dateStringForSectionTitle(title)
        }

        return headerView
    }
}

DATASource — 6.1.0

17 Oct 19:31
Compare
Choose a tag to compare

Adds

/**
 Requests to reload the contents of the cell at a specific indexPath.
 - parameter cell: The cell to be loaded.
 - parameter indexPath: The indexPath where the cell is located.
 */
public func configure(_ cell: UIView, indexPath: IndexPath)

This is the method used internally by DATASource when a cell gets dequeued, for most cases it serves the purpose. In iOS 8 a new API got introduced collectionView(_:willDisplay:forItemAt:) this is the method called by UICollectionView when the cell requires content to be loaded. For most cases collectionView(_:cellForItemAt:) achieves this, but for some specific cases, such as lazy loading images then you need to implement collectionView(_:willDisplay:forItemAt:).

Why doesn't DATASource just call willDisplay for me?

That's because collectionView(_:willDisplay:forItemAt:) is part of the UICollectionViewDelegate, meanwhile DATASource only takes care of the UICollectionViewDataSource.

The main reason is that

Most cases

This will be used internally for DATASource, you don't need to do anything. Internally we'll call configure(_ cell:indexPath:) after dequeuing the cell.

func collectionView(UICollectionView, cellForItemAt: IndexPath)

Few specific cases

Specific cases such as making a NSOperation that will download a thumbnail and refresh the collection view when this operation finishes.

func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
    self.dataSource.configure(cell, indexPath: indexPath)
}

DATASource — 6.0.2

09 Oct 10:17
Compare
Choose a tag to compare
  • Fixed demos
  • Fixed a couple of Swift 3 related issues, such as collection headers not working properly
  • Reset cached headers when calling fetch()

DATASource — 6.0.1

30 Sep 15:44
Compare
Choose a tag to compare
  • Moved to new organization

DATASource — 6.0.0

14 Sep 00:52
Compare
Choose a tag to compare
  • Swift 3 migration.

DATASource — 5.10.0

24 Aug 10:30
Compare
Choose a tag to compare

Using blocks for the cell configuration is not the best idea. The initial reason why I went for that alternative was because I didn't liked the other alternative: using a delegate for the cell configuration.
Specially since that would mean that you could use a DATASource instance that did nothing since the configuration block wasn't provided by default.

But I was wrong, even though is not the best paradigm, is a common paradigm. For example you can easily instantiate a UITableView that does nothing. You have to actually implement it's data source before it can display data. It's a common paradigm, not the best, but is not rare neither.

To not break all the existing apps that are using DATASource right now, I'm providing this implementation as an alternative instead of a replacement.

So now you can do:

class ViewController: UITableViewController {
    weak var dataStack: DATAStack?

    convenience init(dataStack: DATAStack) {
        self.init(style: .Plain)

        self.dataStack = dataStack
    }
    lazy var dataSource: DATASource = {
        let request: NSFetchRequest = NSFetchRequest(entityName: "User")
        request.sortDescriptors = [
            NSSortDescriptor(key: "name", ascending: true)
        ]

        let dataSource = DATASource(tableView: self.tableView, cellIdentifier: CustomCell.Identifier, fetchRequest: request, mainContext: self.dataStack!.mainContext)
        dataSource.delegate = self

        return dataSource
    }()

    override func viewDidLoad() {
        super.viewDidLoad()

        self.tableView.dataSource = self.dataSource
}

extension ViewController: DATASourceDelegate {
    func dataSource(dataSource: DATASource, configureTableViewCell cell: UITableViewCell, withItem item: NSManagedObject, atIndexPath indexPath: NSIndexPath) {
        cell.textLabel.text = item.valueForKey("name") as? String ?? ""
    }
}

DATASource — 5.9.1

31 Jul 20:01
Compare
Choose a tag to compare
  • Fix issue with loading out of bounds section #80

Right now the cached sections only get reloaded when a new section gets inserted, but if the section gets inserted using reloadData then DATASource doesn't know that the cached sections should be reloaded. We fix this issue by reloading cached sections when an out of bounds section is found. Although, ideally, this should also be reloaded when doing reloadData.