基本上我有一些对象类,它们的主要功能是充当 tableView 代表。
我想将它添加到一些超类中。当然只有 1 个超类,我想要灵活性。如果后者我想随意将此功能添加到其他类怎么办?
基本上,这些是用于处理用户可以删除或重新排列行等的表格的代码。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSAssert(false, @"Should be called at child View");
return nil;
}
-(Class) classBookmarked
{
assert(false);
return nil;
}
-(void) setEditing:(BOOL)editing animated:(BOOL)animated
{
[self.delegate.tvDelegated setEditing:editing animated:animated];
if (!editing)
{
NSArray * newIds = _arManagedObjectArray.convertArrayOfNSManagedObjectToItsDefaultSelector;
[self varManagedObjectArrayUpdated];
[BGBookmarkStorer vReportBookmarkStatusToServer:newIds Flag:@"update" withClass:self.classBookmarked];
}
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger row = indexPath.row;
[self deleteARow:row];
}
-(void)deleteARow:(NSUInteger) row
{
NSIndexPath * indexPath = [NSIndexPath indexPathForRow:row inSection:0];
[_arManagedObjectArray removeObjectAtIndex:row];
[self.delegate.tvDelegated deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
[self varManagedObjectArrayUpdated];
}
-(void) varManagedObjectArrayUpdated
{
[self.bookmarkStorer vUpdateBookMarkIDwithArray:_arManagedObjectArray];
[self.delegate vUpdateNumberOfStuffs];
}
-(BGBookmarkStorerForPlacesandCatalog *) bookmarkStorer
{
assert(false);
return nil;
}
- (NSArray*) theBookmarkedIDs
{
return self.bookmarkStorer.bookmarkedIDs;
}
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
{
NSMutableArray * mutableBusinessBookmarked= _arManagedObjectArray;
NSManagedObject *bizOrCatToMove = mutableBusinessBookmarked[sourceIndexPath.row];
[mutableBusinessBookmarked removeObjectAtIndex:sourceIndexPath.row];
[mutableBusinessBookmarked insertObject:bizOrCatToMove atIndex:destinationIndexPath.row];
//_arManagedObjectArray=mutableBusinessBookmarked;
[self varManagedObjectArrayUpdated];
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
}