RXSwift 关于tableview的创建(一)

来源:互联网 发布:python 3.0 廖雪峰pdf 编辑:程序博客网 时间:2024/06/08 11:47

//
// WangMuMuVC.swift
// RXFunction
//
// Created by 王木木 on 16/11/1.
// Copyright © 2016年 王木木. All rights reserved.
//

import UIKit
import RxSwift
import RxCocoa

class WangMuMuVC: UIViewController {

let tableView: UITableView = UITableView()let bag: DisposeBag = DisposeBag()var identifier: String       = "Cell"override func viewDidLoad() {    super.viewDidLoad()   tableView.frame = view.bounds   view.addSubview(tableView)    let cellSelf = UITableViewCell.self    tableView.registerClass(cellSelf, forCellReuseIdentifier: identifier)    getModelData()    .bindTo(tableView.rx_itemsWithCellIdentifier(identifier, cellType: cellSelf))    { (row, element, cell) in        cell.textLabel?.text = element.name    }.addDisposableTo(bag)}func getModelData() -> Observable<[PWCellModel]>{    return Observable.just([        PWCellModel(name: "原始密码"),        PWCellModel(name: "新的密码"),        PWCellModel(name: "确认密码")        ]    )}override func didReceiveMemoryWarning() {    super.didReceiveMemoryWarning()    // Dispose of any resources that can be recreated.}

}

struct PWCellModel {

let name: String

}

0 0