MUKDataSource

所属分类:其他
开发工具:Objective-C
文件大小:0KB
下载次数:0
上传日期:2019-10-18 12:08:53
上 传 者sh-1993
说明:  在iOS上存储、组织和加载数据的中心点。准备成为UITableView数据源。,
(A central point to store, organize and load data on iOS. Ready to be your UITableView data source.,)

文件列表:
.travis.yml (293, 2018-02-01)
Example/ (0, 2018-02-01)
Example/.travis.yml (284, 2018-02-01)
Example/MUKDataSource.xcodeproj/ (0, 2018-02-01)
Example/MUKDataSource.xcodeproj/project.pbxproj (50909, 2018-02-01)
Example/MUKDataSource.xcodeproj/project.xcworkspace/ (0, 2018-02-01)
Example/MUKDataSource.xcodeproj/project.xcworkspace/contents.xcworkspacedata (158, 2018-02-01)
Example/MUKDataSource.xcodeproj/xcshareddata/ (0, 2018-02-01)
Example/MUKDataSource.xcodeproj/xcshareddata/xcschemes/ (0, 2018-02-01)
Example/MUKDataSource.xcodeproj/xcshareddata/xcschemes/TestApp.xcscheme (4466, 2018-02-01)
Example/MUKDataSource.xcworkspace/ (0, 2018-02-01)
Example/MUKDataSource.xcworkspace/contents.xcworkspacedata (4827, 2018-02-01)
Example/MUKDataSource/ (0, 2018-02-01)
Example/MUKDataSource/Base.lproj/ (0, 2018-02-01)
Example/MUKDataSource/Base.lproj/LaunchScreen.xib (3703, 2018-02-01)
Example/MUKDataSource/Base.lproj/Main.storyboard (17636, 2018-02-01)
Example/MUKDataSource/Classes/ (0, 2018-02-01)
Example/MUKDataSource/Classes/App Delegate/ (0, 2018-02-01)
Example/MUKDataSource/Classes/App Delegate/AppDelegate.h (274, 2018-02-01)
Example/MUKDataSource/Classes/App Delegate/AppDelegate.m (2028, 2018-02-01)
Example/MUKDataSource/Classes/Data Sources/ (0, 2018-02-01)
Example/MUKDataSource/Classes/Data Sources/Collection/ (0, 2018-02-01)
Example/MUKDataSource/Classes/Data Sources/Collection/Examples/ (0, 2018-02-01)
Example/MUKDataSource/Classes/Data Sources/Collection/Examples/CollectionExamplesDataSource.h (279, 2018-02-01)
Example/MUKDataSource/Classes/Data Sources/Collection/Examples/CollectionExamplesDataSource.m (33001, 2018-02-01)
Example/MUKDataSource/Classes/Data Sources/Page/ (0, 2018-02-01)
Example/MUKDataSource/Classes/Data Sources/Page/PageDataSource.h (223, 2018-02-01)
Example/MUKDataSource/Classes/Data Sources/Page/PageDataSource.m (1986, 2018-02-01)
Example/MUKDataSource/Classes/Data Sources/Sectioned Content Examples/ (0, 2018-02-01)
Example/MUKDataSource/Classes/Data Sources/Sectioned Content Examples/SectionedContentExamplesDataSource.h (255, 2018-02-01)
Example/MUKDataSource/Classes/Data Sources/Sectioned Content Examples/SectionedContentExamplesDataSource.m (259, 2018-02-01)
Example/MUKDataSource/Classes/Data Sources/Table/ (0, 2018-02-01)
Example/MUKDataSource/Classes/Data Sources/Table/Examples/ (0, 2018-02-01)
Example/MUKDataSource/Classes/Data Sources/Table/Examples/TableExamplesDataSource.h (269, 2018-02-01)
Example/MUKDataSource/Classes/Data Sources/Table/Examples/TableExamplesDataSource.m (33789, 2018-02-01)
Example/MUKDataSource/Classes/Data Sources/Table/Playground/ (0, 2018-02-01)
Example/MUKDataSource/Classes/Data Sources/Table/Playground/TablePlaygroundDataSource.h (418, 2018-02-01)
Example/MUKDataSource/Classes/Data Sources/Table/Playground/TablePlaygroundDataSource.m (2875, 2018-02-01)
Example/MUKDataSource/Classes/Data Sources/Titles/ (0, 2018-02-01)
... ...

# MUKDataSource [![CI Status](http://img.shields.io/travis/muccy/MUKDataSource.svg?style=flat)](https://travis-ci.org/muccy/MUKDataSource) [![Version](https://img.shields.io/cocoapods/v/MUKDataSource.svg?style=flat)](http://cocoadocs.org/docsets/MUKDataSource) [![License](https://img.shields.io/cocoapods/l/MUKDataSource.svg?style=flat)](http://cocoadocs.org/docsets/MUKDataSource) [![Platform](https://img.shields.io/cocoapods/p/MUKDataSource.svg?style=flat)](http://cocoadocs.org/docsets/MUKDataSource) `MUKDataSource` is class designed to provide data (it's not too surprising, I think). It gives a structure to provide immutable data to your views. When you change data you get update to apply. `MUKDataSource` is ready to back a `UITableView`, `UICollectionView` or `UIPageViewController` instance out of the box but it is designed to hold any kind of data for every kind of usage. ## Usage To run the example project, clone the repo, and run `pod install` from the Example directory first. ## Requirements * iOS 7 SDK. * Minimum deployment target: iOS 7. ## Installation `MUKDataSource` is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your Podfile: pod "MUKDataSource" ## Example Say you want to download and show a list of flowers in you table view. You can download data how you want but [MUKContentFetch](https://github.com/muccy/MUKContentFetch) is a good candidate. Once you have data you set sections and you get an update to apply to your table view. Applying an update means to insert, delete, reload, move sections and items with pretty animations. ```objective-c // FlowersFetch contains download+parse logic MUKContentFetch *fetch = [[FlowersFetch alloc] init]; [fetch startWithCompletionHandler:^(MUKContentFetchResponse *response) { if (response.resultType == MUKContentFetchResultTypeSuccess) { MUKDataSourceContentSection *section = [[MUKDataSourceContentSection alloc] initWithIdentifier:@"flowers" items:response.object header:@"Flowers" footer:nil]; MUKDataSourceTableUpdate *update = [self.dataSource setTableSections:@[section]]; [update applyToTableView:self.tableView withAnimation:[MUKDataSourceTableUpdateAnimation automaticAnimation]]; } else if (response.resultType == MUKContentFetchResultTypeFailed) { MUKDataSourceContentPlaceholder *placeholder = [[MUKDataSourceContentPlaceholder alloc] initWithTitle:@"Error" subtitle:[response.error localizedDescription] image:nil]; self.dataSource.content = placeholder; } }]; ``` Data source to show items in table view is trivial because you only need to provide cells. ```objective-c @interface FlowersDataSource : MUKDataSource @end @implementation FlowersDataSource - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *const kCellIdentifier = @"FlowerCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier]; if (!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellIdentifier]; } Flower *flower = [self itemAtIndexPath:indexPath]; cell.textLabel.text = flower.name; return cell; } @end ``` If you subclass `MUKTableViewController` you only need to set data source which automatically attached to table view. ```objective-c @interface FlowersTableViewController : MUKTableViewController @end @implementation FlowersTableViewController - (void)viewDidLoad { [super viewDidLoad]; self.dataSource = [[FlowersDataSource alloc] init]; } @end ``` ## Author Marco Muccinelli, muccymac@gmail.com ## License `MUKDataSource` is available under the MIT license. See the LICENSE file for more info.

近期下载者

相关文件


收藏者