简体   繁体   中英

Can i use ReactiveCocoa in swift 3?

I have to use Reactive Cocoa or RxSwift in the following code for dynamic label height and dynamic row height.

Can I use Reactive Cocoa in Swift3? And What is the difference between ReactiveCocoa and RxSwift?

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell: BTSTableViewCell = self.tableView.dequeueReusableCell(withIdentifier: "BTSTableViewCellIdentifier")! as! BTSTableViewCell

    cell.configureWithPost(posts[indexPath.row])
    cell.delegate = self
    return cell

}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {

    // 259.5+ labelHeight+ bigImageHeight

    let postViewModel = posts[indexPath.row]

    //caption height
    var captionHeight = postViewModel.textDetail?.height(withConstrainedWidth: tableView.bounds.size.width - 20, font: UIFont.systemFont(ofSize: 17))

    captionHeight = ceil(captionHeight!)

    var finalCaptionHeight: CGFloat = 0.0;

    if postViewModel.showDetailedCaption {
        finalCaptionHeight = captionHeight!
    }
    else {
        finalCaptionHeight = min(41, captionHeight!)
    }
    return 259.5 + postViewModel.getBigImageHeightFor(tableView.bounds.size.width) + finalCaptionHeight

}

Can I use Reactive Cocoa in Swift3?

Yes you can. The project is located here . It's important to note that ReactiveCocoa will only have the UI bindings, while the actual "engine" is called ReactiveSwift .

And What is the difference between ReactiveCocoa and RxSwift?

You can find a comparison here . But bottom line, both are two very capable frameworks. You won't get it wrong independently of which one you pick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM