# Cocoa Bindings on OS X Tutorial

**URL:** <https://forums.kodeco.com/t/cocoa-bindings-on-os-x-tutorial/14930>\
**Category:** 🎓 Courses & Articles\
**Created:** [May 17, 2016, 1:00pm UTC](https://forums.kodeco.com/t/cocoa-bindings-on-os-x-tutorial/14930 "2016-05-17T13:00:52Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![fattjake](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/fattjake/32/90552_2.png) [@fattjake](https://forums.kodeco.com/u/fattjake)\
**Post date:** [May 17, 2016, 1:00pm UTC](https://forums.kodeco.com/t/cocoa-bindings-on-os-x-tutorial/14930/1 "2016-05-17T13:00:52Z")

</div>

Cocoa bindings make glue code a thing of the past. Discover how you can simplify your controller code in this Cocoa Bindings on OS X Tutorial!

* * *
 This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/1150-cocoa-bindings-on-os-x-tutorial](https://www.raywenderlich.com/1150-cocoa-bindings-on-os-x-tutorial)

---

<div class="post-metadata">

**Author:** ![gargoyle](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/gargoyle/32/107285_2.png) [@gargoyle](https://forums.kodeco.com/u/gargoyle)\
**Post date:** [May 18, 2016, 3:39am UTC](https://forums.kodeco.com/t/cocoa-bindings-on-os-x-tutorial/14930/2 "2016-05-18T03:39:22Z")

</div>

Nice tutorial, thanks. I’m really hoping there a followup imminently coming which will show how to incorporate NSUndoManager into bindings, and especially how to tie Core Data into this.

---

<div class="post-metadata">

**Author:** ![cgthxon](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/cgthxon/32/44975_2.png) [@cgthxon](https://forums.kodeco.com/u/cgthxon)\
**Post date:** [May 18, 2016, 5:27am UTC](https://forums.kodeco.com/t/cocoa-bindings-on-os-x-tutorial/14930/3 "2016-05-18T05:27:38Z")

</div>

Great tutorial, thanks! 🙂  
Do you have any knowledge about any OS X books being developed by [Raywenderlich.com](http://Raywenderlich.com) team?

---

<div class="post-metadata">

**Author:** ![bsherman](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/bsherman/32/32707_2.png) [@bsherman](https://forums.kodeco.com/u/bsherman)\
**Post date:** [May 18, 2016, 4:28pm UTC](https://forums.kodeco.com/t/cocoa-bindings-on-os-x-tutorial/14930/4 "2016-05-18T16:28:55Z")

</div>

Great tutorial! I did find a minor error under “Binding Text Fields to Their Properties”. Where you write “The Controller Key should be objectValue.trackName.” I think Controller Key should be Model Key Path. That tripped me up for a bit.

---

<div class="post-metadata">

**Author:** ![eww](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/eww/32/81494_2.png) [@eww](https://forums.kodeco.com/u/eww)\
**Post date:** [May 19, 2016, 5:32pm UTC](https://forums.kodeco.com/t/cocoa-bindings-on-os-x-tutorial/14930/5 "2016-05-19T17:32:49Z")

</div>

Really enjoyed this tutorial. Thanks for posting.

---

<div class="post-metadata">

**Author:** ![fattjake](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/fattjake/32/90552_2.png) [@fattjake](https://forums.kodeco.com/u/fattjake)\
**Post date:** [May 19, 2016, 6:58pm UTC](https://forums.kodeco.com/t/cocoa-bindings-on-os-x-tutorial/14930/6 "2016-05-19T18:58:55Z")

</div>

Thanks for catching that, the tutorial has been updated.

---

<div class="post-metadata">

**Author:** ![jacky\_z](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jacky_z/32/32777_2.png) [@jacky\_z](https://forums.kodeco.com/u/jacky_z)\
**Post date:** [May 20, 2016, 7:16am UTC](https://forums.kodeco.com/t/cocoa-bindings-on-os-x-tutorial/14930/7 "2016-05-20T07:16:46Z")

</div>

Great tutorial! Thanks a lot!

May I ask a question that why there’s `self.willChangeValueForKey` and `self.didChangeValueForKey` for `screenShots` but no such pieces of code for `artworkImage`?

When should I use these code in binding?

Any reply will be huge appreciate.

---

<div class="post-metadata">

**Author:** ![amtourky](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/amtourky/32/43863_2.png) [@amtourky](https://forums.kodeco.com/u/amtourky)\
**Post date:** [October 10, 2016, 3:00pm UTC](https://forums.kodeco.com/t/cocoa-bindings-on-os-x-tutorial/14930/8 "2016-10-10T15:00:34Z")

</div>

In general, you should use will/didChangeValueForKey if you are going to affect a value in-directly, for example if you have a Class Student and it has firstName, lastName and fullName where fullName is getting and setting in firstName and lastName, then on changing firstName or lastName you should call will/didChangeValueForKey fullName

---

<div class="post-metadata">

**Author:** ![amtourky](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/amtourky/32/43863_2.png) [@amtourky](https://forums.kodeco.com/u/amtourky)\
**Post date:** [October 10, 2016, 3:02pm UTC](https://forums.kodeco.com/t/cocoa-bindings-on-os-x-tutorial/14930/9 "2016-10-10T15:02:11Z")

</div>

Great cocoa binding article Jake. Been using it for a couple of years. you can also use binding in a more dynamic way duplicate-free views also using DryView: here it is and a sample project using it [Reusable XIBs in cocoa binding (DRY Views) NSView, Part 2 – AMTourky](https://amtourky.me/2016/09/26/reusable-xibs-in-cocoa-binding-dry-views-nsview-part-2/)

---

<div class="post-metadata">

**Author:** ![joneskind](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/joneskind/32/55681_2.png) [@joneskind](https://forums.kodeco.com/u/joneskind)\
**Post date:** [January 26, 2017, 7:35pm UTC](https://forums.kodeco.com/t/cocoa-bindings-on-os-x-tutorial/14930/10 "2017-01-26T19:35:44Z")

</div>

It seems that the sources of this tutorial won’t build anymore. I’ll be glad to get an update ! And many thanks for all your work !

---

<div class="post-metadata">

**Author:** ![paulm](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/paulm/32/59746_2.png) [@paulm](https://forums.kodeco.com/u/paulm)\
**Post date:** [March 9, 2017, 9:12pm UTC](https://forums.kodeco.com/t/cocoa-bindings-on-os-x-tutorial/14930/11 "2017-03-09T21:12:52Z")

</div>

Great tutorial on Cocoa bindings

To get this working with Xcode 8 and Swift 3, I made the following changes after accepting defaults of the automatic conversion process and applying the suggested project changes etc.

1. iTunesResults.swift  
Line 36, changed to  
dynamic var artworkURL : URL!

2. iTunesRequestManager.swift  
Line 39, changed to  
let itunesData : [String : Any] = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as! [String : Any]
