Josep Rodriguez
Jul 21, 2017 · 1 min read

As a suggestion, consider changing the extension to:

extension NSCoder {
class var empty: NSCoder {
let data = NSMutableData()
let archiver = NSKeyedArchiver(forWritingWith: data) archiver.finishEncoding() return NSKeyedUnarchiver(forReadingWith: data as Data) }
}

This would allow you to later use stuff like:

MyViewController(coder: .empty)

Which makes for a nicer API on the consumer (though with your approach you could use just .empty())

)
Josep Rodriguez

Written by

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade