swift 4.0 自己遇到的一些变化

自己遇到的一些swift4的变化做一个记录,持续更新添加

字符串String

  • 截取(原subString)

 //swift 4
let   from = String(cString[index...])  // let from = cString.substring(from: index)
let to = String(cString[..
  • 一些属性,现在可以直接使用的

    • 字符串长度
    let count = string.count  // let count = string.characters.count
    

第三方库

  • RxDataSources

// 定义一个dataSource
// swift 4
let dataSource = RxTableViewSectionedReloadDataSource>(configureCell: {
        (dataSource, tableView, indexPath, model) in
        
        return UITableViewCell()
    })
// swift 3
let dataSource = RxTableViewSectionedReloadDataSource>()
dataSource.configureCell =  {
        (dataSource, tableView, indexPath, model) in
        
        return UITableViewCell()
    })
  • RxSwift

// swift4
self.dataArray.asObservable()
            .bind(to: self.tableView.rx.items(dataSource: dataSource))
            .disposed(by: disposeBag)
// swift3 
self.dataArray.asObservable()
            .bind(to: self.tableView.rx.items(dataSource: dataSource))
            .addDisposableTo(disposeBag)

你可能感兴趣的:(swift 4.0 自己遇到的一些变化)