Persistence Sample Using NSCoding

NSCoding offers a straightforward solution for persisting data in iOS. The protocol is easy to use, and great for prototyping or saving simple objects. While Core Data might be more appropriate for complex data that needs to be shared, NSCoding works just fine for internal persisted objects.

The protocol contains only two methods:  init(coder decoder: NSCoder) and  encodeWithCoder(_ encoder: NSCoder) , a coder/ decoder typically being an instance of NSKeyedArchiver or NSKeyedUnarchiver, which are both subclasses of NSCoder.

This sample app allows a user to choose and name an image using  UIImagePicker , then save and display that image in a  UITableView . Continue reading

Simple UISearchController Implementation

New for iOS 8, Apple has introduced a replacement for its UISearchDisplayController API called UISearchController. I’ll admit, it took me some time to figure out how to use it, but the iOS Developer Library came to the rescue with an outstanding sample app called Table Search with UISearchController. I’ve adapted parts of Apple’s example to create a much simpler, bare bones implementation here. At the least, it will help you get a simple foundation working that you can build on or work into an existing app.

TableView Search using UISearchController

As of this writing, I’m using XCode 6.1 and assuming the reader is familiar with the basics of its use.

To start, create a new iOS project in XCode using the Single View Application template. We’ll be deleting everything, but this will set up the storyboard for us. Continue reading