Skip to content

Commit fb982e4

Browse files
committed
2 parents 79c6976 + 0e55a96 commit fb982e4

9 files changed

Lines changed: 29 additions & 23 deletions

File tree

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ TLIndexPathTools is a small set of classes that can greatly simplify your table
1111

1212
TLIndexPathTools is as lightweight as you want it to be. Start small by using `TLIndexPathDataModel` as your data model (instead of an array) and gain the ability to easily organize data into sections and simplify your view controller with APIs like `[dataModel numberOfRowsInSection:]`, `[dataModel itemAtIndexPath:]`, and `[dataModel indexPathForItem:]`. Or keep reading to learn about automatic batch updates, easier Core Data integration and more.
1313

14-
##Installation
14+
## Installation
1515

1616
Add "TLIndexPathTools" to your podfile or, if you're not using CocoaPods:
1717

@@ -21,7 +21,7 @@ Add "TLIndexPathTools" to your podfile or, if you're not using CocoaPods:
2121

2222
<!--CoreData is required for Core Data integration and because `TLIndexPathSectionInfo` implements the `NSFetchedResultsSectionInfo` protocol. QuartzCore is required because the Grid extension uses it.-->
2323

24-
##Overview
24+
## Overview
2525

2626
`NSArray` is the standard construct for simple table and collection view data models. However, if multiple sections are involved, the typical setup is an `NSArray` containing section names and an `NSDictionary` of `NSArrays` containing data items, keyed by section name. Since table and collection views work with `NSIndexPaths`, the following pattern is used repeatedly in data source and delegate methods:
2727

@@ -43,7 +43,7 @@ Most of the functionality in TLIndexPathTools can be accomplished with just `TLI
4343

4444
This version of TLIndexPathTools is designed to handle up to a few thousand items. Larger data sets may have performance issues.
4545

46-
###TLIndexPathDataModel
46+
### TLIndexPathDataModel
4747

4848
`TLIndexPathDataModel` is an immutable object you use in your view controller to hold your data items instead of an array (or dictionary of arrays, for multiple sections). There are four initializers, a basic one and three for handling multiple sections:
4949

@@ -91,7 +91,7 @@ dataModel.sections;
9191

9292
As an immutable object, all of the properties and methods in `TLIndexPathDataModel` are read-only. So using the data model is very straightforward once you've selected the appropriate initializer.
9393

94-
###TLIndexPathUpdates
94+
### TLIndexPathUpdates
9595

9696
`TLIndexPathUpdates` is a companion class to `TLIndexPathDataModel` for batch updates. You provide two versions of your data model to the initializer and the inserts, deletes, and moves are calculated. Then call either `performBatchUpdatesOnTableView:` or `performBatchUpdatesOnCollectionView:` to perform the updates.
9797

@@ -113,7 +113,7 @@ TLIndexPathUpdates *updates = [[TLIndexPathUpdates alloc] initWithOldDataModel:o
113113
114114
Thats all it takes!
115115
116-
###TLIndexPathController
116+
### TLIndexPathController
117117
118118
`TLIndexPathController` is TLIndexPathTools' version of `NSFetchedResultsController`. It should not come as a surprise, then, that you must use this class if you want to integrate with Core Data.
119119
@@ -199,7 +199,7 @@ The `willUpdateDataModel` delegate method is a really cool feature of `TLIndexPa
199199
}
200200
```
201201

202-
###TLTableViewController & TLCollectionViewController
202+
### TLTableViewController & TLCollectionViewController
203203

204204
`TLTableViewController` and `TLCollectionViewController` are table and collection view base classes that use `TLIndexPathController` and implement the essential data source and delegate methods to get you up and running quickly. Both classes look much like the code outlined above for integrating with `TLIndexPathController`.
205205

@@ -209,12 +209,15 @@ Both classes support view controller-backed cells. Enabling this feature is as e
209209

210210
Most of the sample projects are based on `TLTableViewController` or `TLCollectionViewController`, so a brief perusal will give you a good idea what can be accomplished with a few lines of code.
211211

212-
##Documentation
212+
## Documentation
213213

214214
The Xcode docset can be generated by running the Docset project. The build configuration assumes [Appledoc][6] is installed at /usr/local/bin/appledoc. This can be changed at TLIndexPathTools project | Docset target | Build Phases tab | Run Script.
215215

216216
The API documentation is also [available online][7].
217217

218+
## About SwiftKick Mobile
219+
We build high quality apps! [Get in touch](http://www.swiftkickmobile.com) if you need help with a project.
220+
218221
[1]:https://github.com/wtmoose/TLIndexPathTools/blob/master/Examples/Settings/Settings/SettingsTableViewController.m
219222
[2]:https://github.com/wtmoose/TLIndexPathTools/blob/master/Examples/Collapse/Collapse/CollapseTableViewController.m
220223
[3]:https://github.com/wtmoose/TLIndexPathTools/blob/master/Examples/Outline/Outline/OutlineTableViewController.m

TLIndexPathTools.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@
532532
"$(inherited)",
533533
);
534534
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
535+
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
535536
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
536537
GCC_WARN_UNDECLARED_SELECTOR = YES;
537538
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
@@ -571,6 +572,7 @@
571572
ENABLE_STRICT_OBJC_MSGSEND = YES;
572573
GCC_NO_COMMON_BLOCKS = YES;
573574
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
575+
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
574576
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
575577
GCC_WARN_UNDECLARED_SELECTOR = YES;
576578
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;

TLIndexPathTools/Controllers/TLIndexPathController.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ extern NSString * kTLIndexPathUpdatesKey;
6060
it can be replaced with a model containing a "no results" item.
6161
6262
@param controller the index path controller that sent the message.
63-
@param updates the updates object that can be used to perform batch updates on a table or collection view.
63+
@param oldDataModel the old data model used before the update.
64+
@param updatedDataModel the new data model returned after the update.
6465
@returns an alternative data model to use instead of `updatedDataModel` or `nil` to use `updatedDataModel`
6566
6667
*/
@@ -167,7 +168,7 @@ extern NSString * kTLIndexPathUpdatesKey;
167168
/**
168169
Returns an index path controller initialized with the given items.
169170
170-
@param items the aray of items
171+
@param items the array of items
171172
@return the index path controller with a default data model representation of the given items
172173
173174
A default data model is initialized with items where the properties `identifierKeyPath`,
@@ -187,15 +188,15 @@ extern NSString * kTLIndexPathUpdatesKey;
187188
Returns an index path controller initialized with the given fetch request and
188189
configuration parameters.
189190
190-
@param fetchRequest
191-
@param context
192-
@param sectionNameKeyPath
193-
@param identifierKeyPath
194-
@param cacheName
191+
@param fetchRequest the fetch request used to do the fetching
192+
@param context the managed object context used to fetch objects
193+
@param sectionNameKeyPath the key path on the fetched objects used to determine the section they belong to
194+
@param identifierKeyPath how the identifier should be generated
195+
@param cacheName the name of the file used to cache section information
195196
@return the index path controller with a default data model representation of the given fetch request
196197
197198
*/
198-
- (instancetype)initWithFetchRequest:(NSFetchRequest *)fetchRequest managedObjectContext:(NSManagedObjectContext *)context sectionNameKeyPath:(NSString * __nullable)sectionNameKeyPath identifierKeyPath:(NSString * __nullable)identifierKeyPath cacheName:(NSString * __nullable)name;
199+
- (instancetype)initWithFetchRequest:(NSFetchRequest *)fetchRequest managedObjectContext:(NSManagedObjectContext *)context sectionNameKeyPath:(NSString * __nullable)sectionNameKeyPath identifierKeyPath:(NSString * __nullable)identifierKeyPath cacheName:(NSString * __nullable)cacheName;
199200

200201
#pragma mark - Configuration information
201202
/** @name Configuration information */
@@ -283,7 +284,7 @@ extern NSString * kTLIndexPathUpdatesKey;
283284
fetch request (and perform fetch), in-memory sort descriptors, and in-memory
284285
predicate as a single update.
285286
286-
@param udpates a block that makes changes to the controller
287+
@param updates a block that makes changes to the controller
287288
@param completion a block to be executed after the batch updates are performed.
288289
Note that controller:didUpdateDataModel: is called before this block.
289290

TLIndexPathTools/Controllers/TLIndexPathController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ - (instancetype)initWithDataModel:(TLIndexPathDataModel *)dataModel
6262
return self;
6363
}
6464

65-
- (id)initWithFetchRequest:(NSFetchRequest *)fetchRequest managedObjectContext:(NSManagedObjectContext *)context sectionNameKeyPath:(NSString *)sectionNameKeyPath identifierKeyPath:(NSString *)identifierKeyPath cacheName:(NSString *)name
65+
- (id)initWithFetchRequest:(NSFetchRequest *)fetchRequest managedObjectContext:(NSManagedObjectContext *)context sectionNameKeyPath:(NSString *)sectionNameKeyPath identifierKeyPath:(NSString *)identifierKeyPath cacheName:(NSString *)cacheName
6666
{
6767
TLIndexPathDataModel *dataModel = [[TLIndexPathDataModel alloc] initWithItems:@[] sectionNameKeyPath:sectionNameKeyPath identifierKeyPath:identifierKeyPath];
6868
if (self = [self initWithDataModel:dataModel]) {
6969
//initialize the backing controller with nil sectionNameKeyPath because we don't require
7070
//items to be sorted by section, but NSFetchedResultsController does.
71-
_backingController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:context sectionNameKeyPath:sectionNameKeyPath cacheName:name];
71+
_backingController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:context sectionNameKeyPath:sectionNameKeyPath cacheName:cacheName];
7272
_backingController.delegate = self;
7373
}
7474
return self;

TLIndexPathTools/Data Model/TLIndexPathItem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ NS_ASSUME_NONNULL_BEGIN
6868

6969
@end
7070

71-
NS_ASSUME_NONNULL_END
71+
NS_ASSUME_NONNULL_END

TLIndexPathTools/Data Model/TLIndexPathItem.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ + (NSArray *)identifiersForIndexPathItems:(NSArray *)indexPathItems
4949

5050
- (NSUInteger)hash
5151
{
52-
NSInteger hash = 0;
52+
NSUInteger hash = 0;
5353
hash += 31 * hash + [self.identifier hash];
5454
hash += 31 * hash + [self.sectionName hash];
5555
hash += 31 * hash + [self.cellIdentifier hash];

TLIndexPathTools/Data Model/TLIndexPathSectionInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ NS_ASSUME_NONNULL_BEGIN
4242
- (instancetype)initWithItems:(NSArray *)items name:(NSString * __nullable)name indexTitle:(NSString * __nullable)indexTitle;
4343
@end
4444

45-
NS_ASSUME_NONNULL_END
45+
NS_ASSUME_NONNULL_END

TLIndexPathTools/Extensions/No Results/TLNoResultsTableDataModel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@
3333
@property (strong, nonatomic, readonly) NSString *blankCellIdentifier;
3434
@property (strong, nonatomic, readonly) NSString *noResultsCellIdentifier;
3535
@property (strong, nonatomic, readonly) NSString *noResultsText;
36-
- initWithRows:(NSInteger)rows blankCellId:(NSString *)blankCellId noResultsCellId:(NSString *)noResultsCellId noResultsText:(NSString *)noResultsText;
36+
- (instancetype)initWithRows:(NSInteger)rows blankCellId:(NSString *)blankCellId noResultsCellId:(NSString *)noResultsCellId noResultsText:(NSString *)noResultsText;
3737
@end

TLIndexPathTools/Extensions/No Results/TLNoResultsTableDataModel.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
@implementation TLNoResultsTableDataModel
2828

29-
- (id)initWithRows:(NSInteger)rows blankCellId:(NSString *)blankCellId noResultsCellId:(NSString *)noResultsCellId noResultsText:(NSString *)noResultsText
29+
- (instancetype)initWithRows:(NSInteger)rows blankCellId:(NSString *)blankCellId noResultsCellId:(NSString *)noResultsCellId noResultsText:(NSString *)noResultsText
3030
{
3131
rows = MAX(rows, 1);
3232
NSMutableArray *items = [[NSMutableArray alloc] initWithCapacity:rows];

0 commit comments

Comments
 (0)