Files
libr-ios/librx/PostsStore.swift
2015-11-18 21:42:59 +08:00

26 lines
683 B
Swift

//
// 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
}
}