For my project I've made base cell

class TableViewCell: UITableViewCell {

   private(set) var disposeBag = DisposeBag()

   override func prepareForReuse() {
super.prepareForReuse()
disposeBag = DisposeBag() // because life cicle of every cell ends on prepare for reuse
}
}

and now in your cell factory you should do:

let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! DiaryItemCell

cell.commentButton.rx_tap
.subscribeNext{
showAlert("Hi")
}.addDisposableTo(cell.disposeBag) return cell

All disposables (CompositeDisposable, SerialDisposable, AnonymousDisposable ...) have the same behavior.

  • once they are disposed, adding another disposable with addDisposable will call disposeimmediately (@sergdot that's why self.compositeDisposable.dispose() was causing that weird behavior ;)
  • they don't call dispose automatically on deinit

All classes named *Disposable are meant to be used while implementing your own Rx operators.

DisposeBag is meant to return ARC like memory management to subscriptions, and it will dispose all subscriptions (Disposables) it contains on deinit.

Hope this clears things up :)

 
 

cell reuse & disposebag的更多相关文章

  1. How To Make A Swipeable Table View Cell With Actions – Without Going Nuts With Scroll Views

    How To Make A Swipeable Table View Cell With Actions – Without Going Nuts With Scroll Views  Ellen S ...

  2. 关于使用uitableview 中cell 来实现uiimageview的复用和图片的异步加载

    apple sample lazytableimages 1,首先设置横向显示的uitableview self.customTableview.transform = CGAffineTransfo ...

  3. socket网络间通信初识

    NSOperation: 1. 指定同一时间最大执行的操作数 queue.max…… 2. 设定队列中的任务时间的依赖关系 task1 依赖于 task2: task2 —> task1 3. ...

  4. iphone Dev 开发实例9:Create Grid Layout Using UICollectionView in iOS 6

    In this tutorial, we will build a simple app to display a collection of recipe photos in grid layout ...

  5. 二、UITableView和它的亲戚们

    . UITableView 参考: https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITableView ...

  6. [翻译] Haneke(处理图片缓存问题)

    Haneke https://github.com/hpique/Haneke A lightweight zero-config image cache for iOS. 轻量级0配置图片缓存. H ...

  7. [翻译] SWTableViewCell

    SWTableViewCell An easy-to-use UITableViewCell subclass that implements a swippable content view whi ...

  8. UITableView使用指南

    本文转载至 http://blog.csdn.net/yu0089/article/details/8227402 一.概述 UITableView是iOS开发比不可少也是最重要的一个控件类.可以说任 ...

  9. ios 布局 素材 待整理

    https://www.cnblogs.com/fxwl/p/5961372.html div区域 8.盒子模型的相关属性 margin(外边距/边界) border(边框) padding(内边距/ ...

随机推荐

  1. MVC中AuthConfig的作用 -- ASP.NET MVC 4 使用 OAuth

    ASP.NET MVC 4 使用 OAuth 这个教程向你展示了如何创建一个ASP.NET MVC 4的web应用,能让用户用外部提供方的证书(比如Facebook, Twitter, Microso ...

  2. MySQL日志Undo&Redo

    00 – Undo LogUndo Log 是为了实现事务的原子性,在MySQL数据库InnoDB存储引擎中,还用Undo Log来实现多版本并发控制(简称:MVCC). - 事务的原子性(Atomi ...

  3. MVC3+EF4.1学习系列(八)-----利用Repository and Unit of Work重构项目

    项目最基础的东西已经结束了,但是现在我们的项目还不健全  不利于测试 重复性代码多   层与层之间耦合性高  不利于扩展等问题.今天的这章 主要就是解决这些问题的.再解决这些问题时,自己也产生了很多疑 ...

  4. digitalocean教程:你应该知道的10件事

    DigitalOcean VPS性价比高,全球拥有多处机房,无须备案,非常适合守规矩的中国用户使用.digitalocean优惠码.digitalocean速度.digitalocean评测是网友关心 ...

  5. redis数据类型:lists

    redis的list类型其实就是一个每个子元素都是string类型的双向链表. 我们可以通过push,pop操作从链表的头部或者尾部添加删除元素,这样list即可以作为 栈,又可以作为队列. lpus ...

  6. UPX3.03+UpolyX.5 Shell v1.0 汉化绿色版

    软件名称:UPX3.03+UpolyX.5 Shell v1.0 汉化绿色版软件类别:汉化软件运行环境:Windows软件语言:简体中文授权方式:免费版软件大小:635 KB软件等级:整理时间:201 ...

  7. BJFU 1397 致我们终将逝去的爱情

      LIS 由于要记录轨迹,所以不能用O(nlogn)优化,直接dp加father记录每个节点的转移. #include<cstdio> #include<algorithm> ...

  8. Linux通过XAMPP集成软件包搭建LAMPP环境

    前面介绍过一篇“Linux手动搭建LAMP环境”,今天再来整理一篇“Linux通过XAMPP集成软件包搭建LAMPP环境”. 其实当初整理通过XAMPP集成软件包搭建LAMPP环境的原因是这样的: 自 ...

  9. 借助nginx搭建反向代理服务器小例

    1 反向代理: 反向代理(Reverse Proxy)方式是指以代理服务器接收internet上的连接请求,然后将请求转发给内部网络上的服务器,并将从服务器上得到的结果返回给internet上请求连接 ...

  10. Java自学之路---DotCom

    引言 我从接触编程以来,一直是一个C/C++程序猿,因为我喜欢编程时,那种接地气的感觉,认为只有自己管理内存的使用,心理才踏实.但随着工作中不断增加的见闻,不断的从博客和源码中获得新的见解,我发现这个 ...