-
Notifications
You must be signed in to change notification settings - Fork 8
/
RZCollectionListProtocol.h
87 lines (57 loc) · 2.85 KB
/
RZCollectionListProtocol.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// RZCollectionListProtocol.h
// RZCollectionList
//
// Created by Joe Goullaud on 9/14/12.
// Copyright (c) 2012 Raizlabs. All rights reserved.
//
#import <Foundation/Foundation.h>
#define kRZCollectionListNotificationsLogging 0
@protocol RZCollectionListSectionInfo <NSObject>
@property (nonatomic, readonly) NSString *name;
@property (nonatomic, readonly) NSString *indexTitle;
@property (nonatomic, assign, readonly) NSUInteger numberOfObjects;
@property (nonatomic, readonly) NSArray *objects;
//! Return a copy of this object which returns STATIC values for all properties above
/*!
This is different from NSCopying in the sense that a cachedCopy of section info
should not derive its property values from a dynamic source (source list, etc)
but rather should return a static value for each property.
*/
- (id<RZCollectionListSectionInfo>)cachedCopy;
@end
@protocol RZCollectionListDelegate;
@protocol RZCollectionListObserver;
@protocol RZCollectionList <NSObject>
@required
@property (nonatomic, readonly) NSArray *listObjects;
@property (nonatomic, readonly) NSArray *sections;
@property (nonatomic, readonly) NSArray *cachedSections; // sections cached prior to update, cleared when update is finished
@property (nonatomic, readonly) NSArray *listObservers;
@property (nonatomic, weak) id<RZCollectionListDelegate> delegate;
@property (nonatomic, readonly) NSArray *sectionIndexTitles;
- (id)objectAtIndexPath:(NSIndexPath*)indexPath;
- (NSIndexPath*)indexPathForObject:(id)object;
- (NSString *)sectionIndexTitleForSectionName:(NSString *)sectionName;
- (NSInteger)sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)sectionIndex;
- (void)addCollectionListObserver:(id<RZCollectionListObserver>)listObserver;
- (void)removeCollectionListObserver:(id<RZCollectionListObserver>)listObserver;
@end
@protocol RZCollectionListObserver <NSObject>
typedef enum {
RZCollectionListChangeInvalid = -1,
RZCollectionListChangeInsert = 1,
RZCollectionListChangeDelete = 2,
RZCollectionListChangeMove = 3,
RZCollectionListChangeUpdate = 4
} RZCollectionListChangeType;
@required
- (void)collectionList:(id<RZCollectionList>)collectionList didChangeObject:(id)object atIndexPath:(NSIndexPath*)indexPath forChangeType:(RZCollectionListChangeType)type newIndexPath:(NSIndexPath*)newIndexPath;
- (void)collectionList:(id<RZCollectionList>)collectionList didChangeSection:(id<RZCollectionListSectionInfo>)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(RZCollectionListChangeType)type;
- (void)collectionListWillChangeContent:(id<RZCollectionList>)collectionList;
- (void)collectionListDidChangeContent:(id<RZCollectionList>)collectionList;
@end
@protocol RZCollectionListDelegate <NSObject>
@optional
- (NSString *)collectionList:(id<RZCollectionList>)collectionList sectionIndexTitleForSectionName:(NSString *)sectionName;
@end