Skip to content

Commit

Permalink
Add index path transation and fix date parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
soffes committed May 20, 2012
1 parent 385fa07 commit 6796acd
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
1 change: 0 additions & 1 deletion SSManagedTableViewController.h
Expand Up @@ -19,6 +19,5 @@
- (id)initWithStyle:(UITableViewStyle)style;

- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath;
- (id)objectAtIndexPath:(NSIndexPath *)indexPath;

@end
10 changes: 2 additions & 8 deletions SSManagedTableViewController.m
Expand Up @@ -85,14 +85,6 @@ - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPa
}



#pragma mark - Accessing Objects

- (id)objectAtIndexPath:(NSIndexPath *)indexPath {
return [self.fetchedResultsController objectAtIndexPath:indexPath];
}


#pragma mark - UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
Expand Down Expand Up @@ -168,6 +160,8 @@ - (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)
}

UITableView *tableView = self.tableView;
indexPath = [self viewIndexPathForFetchedIndexPath:indexPath];
newIndexPath = [self viewIndexPathForFetchedIndexPath:newIndexPath];

switch(type) {
case NSFetchedResultsChangeInsert: {
Expand Down
4 changes: 4 additions & 0 deletions SSManagedViewController.h
Expand Up @@ -27,4 +27,8 @@
- (NSString *)sectionNameKeyPath;
- (NSString *)cacheName;

- (NSIndexPath *)viewIndexPathForFetchedIndexPath:(NSIndexPath *)fetchedIndexPath;
- (NSIndexPath *)fetchedIndexPathForViewIndexPath:(NSIndexPath *)viewIndexPath;
- (id)objectForViewIndexPath:(NSIndexPath *)indexPath;

@end
17 changes: 17 additions & 0 deletions SSManagedViewController.m
Expand Up @@ -88,4 +88,21 @@ - (NSString *)cacheName {
return nil;
}


#pragma mark - Accessing Objects

- (NSIndexPath *)viewIndexPathForFetchedIndexPath:(NSIndexPath *)fetchedIndexPath {
return fetchedIndexPath;
}


- (NSIndexPath *)fetchedIndexPathForViewIndexPath:(NSIndexPath *)viewIndexPath {
return viewIndexPath;
}


- (id)objectForViewIndexPath:(NSIndexPath *)indexPath {
return [self.fetchedResultsController objectAtIndexPath:[self fetchedIndexPathForViewIndexPath:indexPath]];
}

@end
2 changes: 1 addition & 1 deletion SSRemoteManagedObject.m
Expand Up @@ -168,7 +168,7 @@ + (NSDate *)parseDate:(id)dateStringOrDateNumber {

// Parse number
if ([dateStringOrDateNumber isKindOfClass:[NSNumber class]]) {
[NSDate dateWithTimeIntervalSince1970:[dateStringOrDateNumber doubleValue]];
return [NSDate dateWithTimeIntervalSince1970:[dateStringOrDateNumber doubleValue]];
}

// Parse string
Expand Down

0 comments on commit 6796acd

Please sign in to comment.