Get Updates By E-mail 

Article Written By:
Johann Dowa

Tutorial: Using Generics To Implement KVO In Swift

  •  
  •  
  •  
  •  
  •  

One of the issues you’ll notice when using Swift is that native key-value-observing is not available and only works with NSObject subclasses.

Swift is changing rapidly and a solution does appear to be on the roadmap for this issue. Until the solution arrives here’s a tutorial from Krzysztof Zablocki illustrating a nice technique for implementing observable properties completely using Swift. This technique uses generics and what’s really nice is that you can create the observable properties without affecting the rest of your code.

You can find the tutorial on the Merowing blog.

A playground demonstrating the technique can be found on Github here.

A nice simple technique for implementing KVO in Swift.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments