关于delegate代理应用场景的套路

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (_delegate && [_delegate respondsToSelector:@selector(conversationListViewController:didSelectConversationModel:)]) {
        EaseConversationModel *model = [self.dataArray objectAtIndex:indexPath.row];
        [_delegate conversationListViewController:self didSelectConversationModel:model];
    } else {
        EaseConversationModel *model = [self.dataArray objectAtIndex:indexPath.row];
        EaseMessageViewController *viewController = [[EaseMessageViewController alloc] initWithConversationChatter:model.conversation.conversationId conversationType:model.conversation.type];
        viewController.title = model.title;
        [self.navigationController pushViewController:viewController animated:YES];
    }
}
@interface ConversationListController : EaseConversationListViewController
 self.delegate = self;

环信这里,父类的代理子类来实现,直接self.delegate = self;

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1、在使用block前需要对block指针做判空处理 2.避免循环引用 block会飞内部的所有对象引用计数加1,...
    大美象阅读 777评论 0 1
  • 不是我考研,是学长学姐考研,但是我却很有感触,看她们这么拼,仿佛看到一年后的自己,也是别人同情的对象,也要经历这么...
    凡夫俗子Au阅读 157评论 0 0
  • 夜市开始热闹 流连人潮,哼着你爱的歌谣 这种优雅,并不是我想要 陌生人,能否坐下陪我聊聊 我们擦肩而过,错过了多少...
    过街阅读 237评论 0 0
  • 股龄三年,仗着初生牛犊不怕虎,跳入了各种坑。 1.追涨 新手的第一次,运气总是很好。我买的第一支股票,从每股10涨...
    爱所有的一切阅读 351评论 5 1
  • 坚持看书写书评,只求可以培养自己独立思考的能力。关于书本身,不求有人因我的书评选择某书,只希望不要因为我的书评而拒...
    不想起名字的三公子阅读 542评论 0 0