Updated for Xcode beta 7 and to limit number of data items saved.