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. JSON.parse()和JSON.stringify()&&traditional(ajax请求)的作用

    parse是一个字符串中解析出json对象,如 var str = '{"name":"haizeiwang"}' 结果: JSON.parse(str) na ...

  2. python3 随机数

    random库 random.random()返回n,则 0 <= n < 1的小数. random.uniform(a,b)    返回n ,则 a <= n <= b的浮点 ...

  3. ECOS- 技术问题答疑[转]

    http://bbs.ec-os.net/read.php?tid=37 1.为什么我购买的是源码版,但是我的base/ego.php(或者base/ego/目录下文件)却是加密的?  答:ego 源 ...

  4. 请教下关于CKEditor富文本编辑框设置字体颜色的问题

    CKEDITOR.editorConfig = function( config ){ config.plugins = 'about,a11yhelp,basicstyles,bidi,blockq ...

  5. 通过httplib2 探索的学习的最佳方式

    在工作中需要对一个视频点播两百次,使其成为热门视频,才能对其p2p情况进行测试.虽然可以手动点播两百次,但是利用python发送200次post请求,能减少很多的工作量.该发送请求的方法用到了http ...

  6. 关于C/C++的四舍五入方向

    今天在刷题过程中发现了一个特别奇怪的现象,printf() 的精度控制不是按照4舍5入,而是按照5舍6入, 例如: printf("%.2f\n",0.145) printf(&q ...

  7. 清除浮动clearfix

    css用clearfix清除浮动 更多2013/11/4 来源:css学习浏览量:11901 学习标签: css clearfix 本文导读:写css 时总为浮动而烦恼,如果用了浮动,浮动的父层不会跟 ...

  8. SQLServer 错误: 15404,无法获取有关 Windows NT 组 用户

    因做服务器数据库迁移,造成的一系列问题, 1.重启SQL 代理,操作也不可. 然后又进行操作: SQL---------安全性------登录名 中原来的系统用户名前的计算机名更改为现在所用的计算机名 ...

  9. linux中将程序加入到开机自动启动

    如果将在linux中将命令或者程序设置为开机自动启动,只需要进入到将对应命令加入到/etc/rc.d/rc.local文件里即可,如下 打开文件,vi /etc/rc.d/rc.local #!/bi ...

  10. 图片(img标签)大小自适应

    $(function(){ var myimg,oldwidth,oldheight; var maxwidth=249; var maxheight=187; var imgs = document ...