基本上我有類的主要功能是充當tableView委託的對象。在objective-c中沒有多重繼承的情況下,最優雅的方法是什麼?
我想補充一些超類。當然,只有一個超類,我想要靈活性。如果後者我想將此功能隨意添加到其他類中,怎麼辦?
基本上這些都用於處理表格,用戶可以刪除或重新排列行代碼等
- (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;
}
我不明白你的意思是'我想把它添加到一些超類.' –