AlphabetTable 0.0.2

AlphabetTable 0.0.2

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Unclaimed.


Downloads

Total70
Week0
Month0

Installs

Apps8
powered by Segment

GitHub

Stars10
Watchers2
Forks2
Issues1
Contributors0
Pull Requests0

Code

Files0
LOCLines of Code 0


  • By
  • Bryce Redd

Alphabet Table

Alphabet table will automatically sort your data objects by letter.

Alphabet Table

To use

Implement the protocol on your data objects:

@protocol ITVAlphabetObject <NSObject>
- (NSString*) title;
@end

Add the data objects to your ITVAlphabetTable instance:

// ITVAlphabetTable* table = [[ITVAlphabetTable...
// NSArray* data = [NSArray arrayWithObject:data... all data objects conform to ITVAlphabetObject protocol

[table addObjectsFromArray:data];
[table reloadData];

Override your cells to make more interesting cells:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  static NSString *cellIdentifier = @"VanillaCell";

  NSObject<ITVAlphabetObject>* object = [self objectForIndexPath:indexPath];

  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

  if(cell == nil) {
      cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  }

  [cell.textLabel setText:object.title];

  return cell;
}