Continued cleanup related to managed object context work

This commit is contained in:
Blake Watters
2012-07-17 13:44:50 -04:00
parent b25a1833b3
commit a8f64e7982
21 changed files with 350 additions and 366 deletions

View File

@@ -83,7 +83,7 @@ typedef void(^RKControlBlockActionBlock)(id sender);
@end
@interface RKTableViewCellMapping ()
@property (nonatomic, retain) NSMutableArray *prepareCellBlocks;
@property (nonatomic, retain) NSMutableArray *mutablePrepareCellBlocks;
@end
@implementation RKTableViewCellMapping
@@ -103,7 +103,7 @@ typedef void(^RKControlBlockActionBlock)(id sender);
@synthesize rowHeight = _rowHeight;
@synthesize deselectsRowOnSelection = _deselectsRowOnSelection;
@synthesize managesCellAttributes = _managesCellAttributes;
@synthesize prepareCellBlocks = _prepareCellBlocks;
@synthesize mutablePrepareCellBlocks = _mutablePrepareCellBlocks;
+ (id)cellMapping
{
@@ -142,7 +142,7 @@ typedef void(^RKControlBlockActionBlock)(id sender);
_selectionStyle = UITableViewCellSelectionStyleBlue;
self.rowHeight = 44;
self.deselectsRowOnSelection = YES;
_prepareCellBlocks = [NSMutableArray new];
self.mutablePrepareCellBlocks = [NSMutableArray array];
}
return self;
@@ -158,7 +158,7 @@ typedef void(^RKControlBlockActionBlock)(id sender);
- (void)dealloc
{
[_reuseIdentifier release];
[_prepareCellBlocks release];
[_mutablePrepareCellBlocks release];
Block_release(_onSelectCell);
Block_release(_onSelectCellForObjectAtIndexPath);
Block_release(_onCellWillAppearForObjectAtIndexPath);
@@ -170,11 +170,6 @@ typedef void(^RKControlBlockActionBlock)(id sender);
[super dealloc];
}
- (NSMutableArray *)prepareCellBlocks
{
return _prepareCellBlocks;
}
- (id)copyWithZone:(NSZone *)zone
{
RKTableViewCellMapping *copy = [super copyWithZone:zone];
@@ -192,8 +187,8 @@ typedef void(^RKControlBlockActionBlock)(id sender);
copy.targetIndexPathForMove = self.targetIndexPathForMove;
copy.rowHeight = self.rowHeight;
@synchronized(_prepareCellBlocks) {
for (void (^block)(UITableViewCell *) in _prepareCellBlocks) {
@synchronized(_mutablePrepareCellBlocks) {
for (void (^block)(UITableViewCell *) in _mutablePrepareCellBlocks) {
void (^blockCopy)(UITableViewCell *cell) = [block copy];
[copy addPrepareCellBlock:blockCopy];
[blockCopy release];
@@ -203,33 +198,6 @@ typedef void(^RKControlBlockActionBlock)(id sender);
return copy;
}
- (id)mappableObjectForData:(UITableView *)tableView
{
NSAssert([tableView isKindOfClass:[UITableView class]], @"Expected to be invoked with a tableView as the data. Got %@", tableView);
RKLogTrace(@"About to dequeue reusable cell using self.reuseIdentifier=%@", self.reuseIdentifier);
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:self.reuseIdentifier];
if (cell) {
RKLogTrace(@"Dequeued existing cell object for reuse identifier '%@': %@", self.reuseIdentifier, cell);
} else {
cell = [[[self.objectClass alloc] initWithStyle:self.style
reuseIdentifier:self.reuseIdentifier] autorelease];
RKLogTrace(@"Failed to dequeue existing cell object for reuse identifier '%@', instantiated new cell: %@", self.reuseIdentifier, cell);
}
if (self.managesCellAttributes) {
cell.accessoryType = self.accessoryType;
cell.selectionStyle = self.selectionStyle;
}
// Fire the prepare callbacks
for (void (^block)(UITableViewCell *) in _prepareCellBlocks) {
block(cell);
}
return cell;
}
- (void)setSelectionStyle:(UITableViewCellSelectionStyle)selectionStyle
{
self.managesCellAttributes = YES;
@@ -278,10 +246,15 @@ typedef void(^RKControlBlockActionBlock)(id sender);
- (void)addPrepareCellBlock:(void (^)(UITableViewCell *cell))block
{
void (^blockCopy)(UITableViewCell *cell) = [block copy];
[_prepareCellBlocks addObject:blockCopy];
[self.mutablePrepareCellBlocks addObject:blockCopy];
[blockCopy release];
}
- (NSArray *)prepareCellBlocks
{
return [NSArray arrayWithArray:self.mutablePrepareCellBlocks];
}
- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents toControlAtKeyPath:(NSString *)keyPath
{
[self addPrepareCellBlock:^(UITableViewCell *cell) {