DeclarativeHub / Bond

A Swift binding framework
MIT License
4.23k stars 361 forks source link

Error #224

Closed Jkurbs closed 8 years ago

Jkurbs commented 8 years ago

Hi, this section of my code is given me errors the errors are :

  1. Use of undeclared type Bond
  2. Value of type 'UIImageView' has no member 'designatedBond'
  3. Value of type 'Observable<UIImage?>' (aka 'Observable<Optional>') has no member 'bonds'

What modification I can do? Thank you very much!

My Code:

weak var timeline: HomeViewController? var postDisposable: DisposableType? var likeDisposable: DisposableType? (error here)---> var likeBond: Bond<[PFUser]?>!

var post:Post? {
    didSet {
        // free memory of image stored with post that is no longer displayed
        if let oldValue = oldValue where oldValue != post {
            likeBond.unbindAll()
       (error)   --->  postImageView.designatedBond.unbindAll()
           ---> if (oldValue.image.bonds.count == 0) {
                oldValue.image.value = nil
            }
        }

        if let post = post {
            // bind the image of the post to the 'postImage' view
         (error)  --->  post.image ->> postImageView

            // bind the likeBond that we defined earlier, to update like label and button when likes change
            post.likes ->> likeBond
        }
    }
}

//MARK: Initialization

required public init(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)!

(error)   ---> likeBond = Bond<[PFUser]?>() { [unowned self] likeList in
        if let likeList = likeList {
            self.likesLabel.text = self.stringFromUserlist(likeList)
            self.likeButton.selected = contains(likeList, PFUser.currentUser()!)
            self.likesIconImageView.hidden = (likeList.count == 0)
        } else {
            // if there is no list of users that like this post, reset everything
            self.likesLabel.text = ""
            self.likeButton.selected = false
            self.likesIconImageView.hidden = true
        }
    }
}
srdanrasic commented 8 years ago

Hi @Jkurbs,

You're using syntax from old, non-supported, version of Bond. Please check out the readme. On bottom of the page you'll also fined migration guide. But you should read whole readme anyway. Hope it'll help.