Repository navigation
Expand file tree
/
Copy pathCDAResourcesCollectionViewController.h
More file actions
108 lines (86 loc) · 3.37 KB
/
Copy pathCDAResourcesCollectionViewController.h
File metadata and controls
108 lines (86 loc) · 3.37 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//
// CDAResourcesCollectionViewController.h
// ContentfulSDK
//
// Created by Boris Bügling on 19/03/14.
//
//
#if __has_feature(modules)
@import UIKit;
#else
#import <UIKit/UIKit.h>
#endif
#import <ContentfulDeliveryAPI/CDAClient.h>
/**
The `CDAResourcesCollectionViewController` makes it easy to display content from different kinds
of Resources in an `UICollectionView`.
*/
@interface CDAResourcesCollectionViewController : UICollectionViewController
/** @name Initializing the CDAResourcesCollectionViewController Object */
/**
* Initializes a new instance with the given cell mapping. The cell mapping is a dictionary, containing
* keypaths to properties on each cell and mapping them to Field identifiers. This is used for
* automatically filling new cells with data from the Resources.
*
* Example:
*
* `@{ @"textLabel.text": @"fields.name" }`
*
* This will set the text of each cell's `textLabel` to the corresponding Entry's value of Field `name`.
*
* @param layout The layout to be used for the collection view.
* @param cellMapping Mapping between cell properties and Resource content.
*
* @return An initialized `CDAResourcesCollectionViewController` or `nil` if the object
* couldn't be created.
*/
-(id __nullable)initWithCollectionViewLayout:(UICollectionViewLayout * __nonnull)layout
cellMapping:(NSDictionary* __nonnull)cellMapping;
/** @name Access Displayed Data */
/** The items which are currently displayed in this view controller's table view. */
@property (nonatomic, readonly) NSArray* __nullable items;
/** @name Configure Data to Fetch */
/**
The client which is used to fetch Resources. Make sure to set it before displaying the view
controller's view or an exception will be thrown unless `initWithCellMapping:items:` was used to
initialize this view controller.
The client is not retained.
*/
@property (nonatomic, weak) CDAClient* __nullable client;
/** Locale to use when querying Resources. */
@property (nonatomic, copy) NSString* __nullable locale;
/**
The query parameters used for fetching Resources. By default, all Resources from the Space associated
with the client will be fetched.
*/
@property (nonatomic) NSDictionary* __nullable query;
/** The type of Resources which ought to be fetched. */
@property (nonatomic) CDAResourceType resourceType;
/**
Activate the built-in support for caching Resources offline.
The cached data will only be used if the device is truly offline, use a `CDASyncedSpace` instead for
general purpose caching.
*/
@property (nonatomic) BOOL offlineCaching;
/** @name Configure Appearance */
/**
Configure whether or not to show a search bar.
The query will be handled automatically, by utilizing the full-text search of Contentful.
*/
@property (nonatomic) BOOL showSearchBar;
/** @name Configuring behaviour in Subclasses */
/**
The collection view's data source is configured to return cells of this class. If you wish to use your
own `UICollectionViewCell` subclass, override this method in your subclass of
`CDAResourcesCollectionViewController`.
*/
+(Class __nonnull)cellClass;
/**
* By default, errors related to requests made to the Contentful API will be displayed in a
* `UIAlertView`. You can override this method in your subclass if you want to implement different
* behaviour.
*
* @param error The error which occured.
*/
-(void)showError:(NSError* __nonnull)error;
@end