Latest 0.1.1
Homepage https://github.com/danielbowden/DBDataSource
License MIT
Platforms ios 6.0, requires ARC
Authors

DBDataSource is an easy to use datasource conforming to both UITableView and UICollectionView that can be dropped in to a project to allow quick population of tableviews and collectionviews. Use the CellConfigureBlock to populate the contents of your cell and initialise the datasource with an array.

There is an example project included. Clone the repo and open "DBDataSourceDemo.xcworkspace".

Basic example with an array of strings and a default tablecell:

CellConfigureBlock configureCell = ^(UITableViewCell *cell, NSString *item) {
    cell.textLabel.text = item;
};

NSArray *myArray = @[@"Demo data 1", @"Demo data 2", @"Demo data 3"];

self.demoDataSource = [[DBDataSource alloc] initWithArray:myArray cellIdentifier:DemoCellIdentifier configureCellBlock:configureCell];

self.tableView.dataSource = self.demoDataSource;

Another example using an array of Person objects and a custom collectionviewcell:

CellConfigureBlock configureCell = ^(DemoCollectionCell *cell, Person *person) {
        [cell populateWithPerson:person];
    };

NSArray *myArray = @[
     [Person personWithFirstName:@"Daniel" lastName:@"Bowden" emailAddress:@"[email protected]"],
     [Person personWithFirstName:@"Buster" lastName:@"Posey" emailAddress:@"[email protected]"],
     [Person personWithFirstName:@"Pablo" lastName:@"Sandoval" emailAddress:@"[email protected]"]
     ];

self.demoDataSource = [[DBDataSource alloc] initWithArray:myArray cellIdentifier:[DemoCollectionCell cellIdentifier] configureCellBlock:configureCell];
self.collectionView.dataSource = self.demoDataSource;

To access an item of the datasource for use in methods such as didSelectSelectItemAtIndexPath or heightForRowAtIndexPath you can use [self.demoDataSource itemAtIndexPath:indexPath];

Installation

DBDataSource is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "DBDataSource"

Author

Daniel Bowden, danielbowden.

License

DBDataSource is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "DBDataSource",
    "version": "0.1.1",
    "summary": "DBDataSource is an easy to use datasource conforming to both UITableView and UICollectionView.",
    "description": "DBDataSource is an easy to use datasource conforming to both UITableView and UICollectionView that can be dropped in to a project to allow quick population of tableviews and collectionviews. Use the CellConfigureBlock to populate the contents of your cell and initialise the datasource with an array.n",
    "homepage": "https://github.com/danielbowden/DBDataSource",
    "license": "MIT",
    "authors": {
        "Daniel Bowden": "[email protected]"
    },
    "source": {
        "git": "https://github.com/danielbowden/DBDataSource.git",
        "tag": "0.1.1"
    },
    "social_media_url": "https://twitter.com/danielgbowden",
    "platforms": {
        "ios": "6.0"
    },
    "requires_arc": true,
    "source_files": "Classes",
    "public_header_files": "Classes/**/*.h"
}

Pin It on Pinterest

Share This