BBAGroupedList.h 1.02 KB
//
//  BBAGroupedList.h
//  BBAPods
//
//  Created by Feng on 30/03/2016.
//  Copyright © 2016 Baidu. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface BBAGroupedList : NSObject

/**
 * 自定义的集合类型,只能通过拼音排序,不够抽象,很难被业务方复用
 * wiki:
 */

- (instancetype)initWithItems:(NSArray *)itmes;

- (NSArray *)items;
- (NSInteger)count;
- (NSInteger)numberOfSections;
- (NSInteger)numberOfRowsInSection:(NSInteger)section;
- (NSString *)titleForSeciton:(NSUInteger)section;
- (NSArray *)titles;
- (id)itemAtIndexPath:(NSIndexPath *)indexPath;
- (NSArray *)itemsWithPattern:(NSString *)pattern;
- (NSIndexPath *)indexPathForItem:(id)item;

- (void)removeItem:(id)item
        completion:(void(^)(NSIndexPath *indexPath, BOOL shouldRemoveSection))completion;
- (void)insertItem:(id)item
        completion:(void(^)(NSIndexPath *indexPath, BOOL shouldInsertSection))completion;

// 需重载
- (NSString *)nameForItem:(id)item;
- (NSPredicate *)predicateWithPattern:(NSString *)pattern;

@end