mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-23 20:31:13 +08:00
Continued cleanup related to managed object context work
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user