IGListKit/Examples/Examples-macOS/IGListKitExamples/View/UserCollectionViewCell.swift
Weyert de Boer bb983cf918 Refactors/macos example
Summary:
Issue fixed: #381

- [X] All tests pass. Demo project builds and runs.
- [ ] I added tests, an experiment, or detailed why my change isn't tested.
- [X] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [X] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
Closes https://github.com/Instagram/IGListKit/pull/915

Differential Revision: D5758006

Pulled By: rnystrom

fbshipit-source-id: cbc3f19b6bb9604d8a6c8c15a16414e558e3b70c
2017-09-01 14:00:52 -07:00

29 lines
694 B
Swift

//
// UserCollectionViewCell.swift
// IGListKitExamples
//
// Created by Weyert de Boer on 27/08/2017.
// Copyright © 2017 Instagram. All rights reserved.
//
import Cocoa
protocol UserCollectionViewCellDelegate: class {
func itemDeleted(_ user: User)
}
final class UserCollectionViewCell: NSCollectionViewItem {
weak var delegate: UserCollectionViewCellDelegate?
@IBAction func deleteButtonClicked(_ sender: AnyObject) {
guard let user = representedObject as? User else { return }
delegate?.itemDeleted(user)
}
func bindViewModel(_ user: User) {
representedObject = user
textField?.stringValue = user.name
}
}