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. php的实参和形参

    1.实参是调用函数时候的参数; 2.形参是声明函数时侯的参数, 例如 public function demo($a,$b) {         return ; } 如果声明的函数如上,调用时dem ...

  2. Java面向对象总复习-QuickHit

    1.创建玩家级别类Level.java package com.bdqn; /** * 1.玩家级别类 * @author pc * */ public class Level { /** * 级别号 ...

  3. 模拟器SDK路径

    I'm guessing you already find it out, but just for the record: the UIKit.framework is available only ...

  4. openwrt源码下载地址(镜像)

    与openwrt.org的源码svn路径仅仅多了一个.cn svn://svn.openwrt.org.cn/openwrt/branches/backfiresvn://svn.openwrt.or ...

  5. vultr vps注册和后台教程

    我用了一年多vultr vps,感觉相当满意.我算是vultr最早的一批用户了,当时他们充值多少赠送多少,吸引大批新用户搬家到vultr,给linode和digitalocean vps不少的市场压力 ...

  6. C++ 类中的引用成员变量初始化

    刚遇到一个问题,需要的类成员为指针的引用,而引用不能在构造函数里初始化,必须在初始化列表中进行初始化,并且需要该引用在构造函数中的形参必须为引用形式 1: class ThreadParam { 2: ...

  7. 仿bootstrap的

    <!doctype html> <html class="no-js"> <head> <meta charset="utf-8 ...

  8. 关于socket客户端接收不定长数据的解决方案

    #!/usr/bin/env python3.5 # -*-coding:utf8-*- """ 本实例客户端用于不断接收不定长数据,存储到变量res "&qu ...

  9. genymotion模拟器配置Genymotion-ARM-Translation 兼容包

    前提是你的adb的环境已经配置正确,不知道怎么配置的可参考http://jingyan.baidu.com/article/17bd8e52f514d985ab2bb800.html 如果还不成功的话 ...

  10. D - 小晴天老师系列——晴天的后花园

    D - 小晴天老师系列——晴天的后花园 Time Limit: 10000/5000MS (Java/Others)    Memory Limit: 128000/64000KB (Java/Oth ...