// // LocalStore.swift // librx // // Created by Yunlong Zheng on 15/8/26. // Copyright (c) 2015年 librx. All rights reserved. // import UIKit struct PostsStore { private static let userDefaults = NSUserDefaults.standardUserDefaults() static func setPostsCacheBySection(section: PostsLoader.PostSection, posts: NSData) { print("set posts cache for key \(section.cacheKey)") userDefaults.setObject(posts, forKey: section.cacheKey) userDefaults.synchronize() } static func getPostsCacheBySection(section: PostsLoader.PostSection) -> NSData?{ return userDefaults.objectForKey(section.cacheKey) as? NSData } }