Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
SentulAsia committed Jul 2, 2019
2 parents 0a653e2 + 357ec2f commit 43f0cb9
Show file tree
Hide file tree
Showing 46 changed files with 120 additions and 191 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![Documentation](https://zaidmsaid.github.io/DataStoreManager/badge.svg)](https://zaidmsaid.github.io/DataStoreManager/)
[![Twitter](https://img.shields.io/badge/[email protected])](http://twitter.com/SentulAsia)

DataStoreManager is a persistent data framework written in Swift and can be used with Objective-C.
[DataStoreManager](https://github.com/zaidmsaid/DataStoreManager) is a persistent data framework written in Swift and can be used with Objective-C.

## Getting Started

Expand Down
42 changes: 20 additions & 22 deletions Sources/DataStoreManager/DataStoreManager+Protocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ import Foundation
/// - Returns: The number of total cost limit.
///
/// When you add an object to the cache, you may pass in a specified cost for the object, such as the size in bytes of the object.
/// If adding this object to the cache causes the cache’s total cost to rise above totalCostLimit, the cache may automatically
/// evict objects until its total cost falls below totalCostLimit. The order in which the cache evicts objects is not guaranteed.
/// If adding this object to the cache causes the cache’s total cost to rise above `totalCostLimit`, the cache may automatically
/// evict objects until its total cost falls below `totalCostLimit`. The order in which the cache evicts objects is not guaranteed.
///
/// This is not a strict limit, and if the cache goes over the limit, an object in the cache could be evicted instantly, at a later
/// point in time, or possibly never, all depending on the implementation details of the cache.
Expand All @@ -65,57 +65,55 @@ import Foundation
/// - Parameters:
/// - manager: An object representing the data store manager requesting this information.
/// - object: The object to be cached.
/// - Returns: The cost value is used to compute a sum encompassing the costs of all the objects in the cache.
/// - Returns: The `cost` value is used to compute a sum encompassing the costs of all the objects in the cache.
///
/// When memory is limited or when the total cost of the cache eclipses the maximum allowed total cost, the cache could begin an
/// eviction process to remove some of its elements. However, this eviction process is not in a guaranteed order. As a consequence,
/// if you try to manipulate the cost values to achieve some specific behavior, the consequences could be detrimental to your program.
/// Typically, the obvious cost is the size of the value in bytes. If that information is not readily available, you should not go
/// through the trouble of trying to compute it, as doing so will drive up the cost of using the cache. Pass in 0 for the cost value
/// if you otherwise have nothing useful to pass, or simply use the setObject:forKey: method, which does not require a cost value to
/// be passed in.
/// if you otherwise have nothing useful to pass.
///
/// Unlike an `NSMutableDictionary` object, a cache does not copy the key objects that are put into it.
@objc optional func dataStoreManager(_ manager: DataStoreManager, cacheCostLimitForObject object: Any) -> Int

// MARK: SecurityItem

/// Asks the data source for the keychain service of the data store manager.
///
/// - Parameter manager: An object representing the data store manager requesting this information.
/// - Returns: The corresponding value is a string of type CFString that represents the service associated with this item.
/// Items of class kSecClassGenericPassword have this attribute.
/// - Returns: The corresponding value is a string of type [CFString](apple-reference-documentation://hsYWZv0wKs)
/// that represents the service associated with this item. Items of class
/// [kSecClassGenericPassword](apple-reference-documentation://hsgWgYNpc3) have this attribute.
@objc optional func keychainService(for manager: DataStoreManager) -> String

/// Asks the data source for the keychain account name of the data store manager.
///
/// - Parameter manager: An object representing the data store manager requesting this information.
/// - Returns: The corresponding value is of type CFString and contains an account name. Items of class kSecClassGenericPassword
/// and kSecClassInternetPassword have this attribute.
/// - Returns: The corresponding value is of type [CFString](apple-reference-documentation://hsYWZv0wKs)
/// and contains an account name. Items of class
/// [kSecClassGenericPassword](apple-reference-documentation://hsgWgYNpc3) and
/// [kSecClassInternetPassword](apple-reference-documentation://hsT6cNjrp9) have this attribute.
@objc optional func keychainAccount(for manager: DataStoreManager) -> String

/// Asks the data source for a string indicating the keychain access group of the data store manager.
///
/// - Parameter manager: An object representing the data store manager requesting this information.
/// - Returns: The corresponding value is of type CFString and indicates the item’s one and only access group.
/// - Returns: The corresponding value is of type [CFString](apple-reference-documentation://hsYWZv0wKs)
/// and indicates the item’s one and only access group.
///
/// For an app to access a keychain item, one of the groups to which the app belongs must be the item’s group.
/// The list of an app’s access groups consists of the following string identifiers, in this order:
/// * The strings in the app’s Keychain Access Groups Entitlement
/// * The strings in the app’s [Keychain Access Groups Entitlement](apple-reference-documentation://hsVfwaZeip)
/// * The app ID string
/// * The strings in the App Groups Entitlement
/// * The strings in the [App Groups Entitlement](apple-reference-documentation://hsSm4ftpCR)
///
/// Two or more apps that are in the same access group can share keychain items. For more details,
/// see Sharing Access to Keychain Items Among a Collection of Apps.
/// see [Sharing Access to Keychain Items Among a Collection of Apps](apple-reference-documentation://ts2972431).
///
/// Specify which access group a keychain item belongs to when you create it by setting the kSecAttrAccessGroup
/// attribute in the query you send to the SecItemAdd(_:_:) method. Naming a group that’s not among the creating
/// app’s access groups—including the empty string, which is always an invalid group—generates an error. If you
/// don’t explicitly set a group, keychain services defaults to the app’s first access group, which is either the
/// first keychain access group, or the app ID when the app has no keychain groups. In the latter case, the item
/// If you don’t explicitly set a group, keychain services defaults to the app’s first access group, which is either
/// the first keychain access group, or the app ID when the app has no keychain groups. In the latter case, the item
/// is only accessible to the app creating the item, since no other app can be in that group.
///
/// By default, the SecItemUpdate(_:_:), SecItemDelete(_:), and SecItemCopyMatching(_:_:) methods search all the
/// app’s access groups. Add the kSecAttrAccessGroup attribute to the query to limit the search to a particular
/// group.
@objc optional func keychainAccessGroup(for manager: DataStoreManager) -> String
}

Expand Down
5 changes: 5 additions & 0 deletions Sources/DataStoreManager/DataStoreManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,19 @@ import Foundation
/// Returns the shared data store manager object.
public static let shared = DataStoreManager()

/// An interface to the UserDefaults.
lazy var userDefaultsWorker: UserDefaultsWorker = {
let worker = UserDefaultsWorker()
worker.dataStoreManager = self
return worker
}()

/// An interface to the FileManager.
lazy var fileManagerWorker: FileManagerWorker = {
FileManagerWorker()
}()

/// An interface to the NSCache.
lazy var cacheWorker: CacheWorker = {
let worker = CacheWorker()
worker.dataStoreManager = self
Expand All @@ -71,6 +74,7 @@ import Foundation
return worker
}()

/// An interface to the SecItem.
lazy var securityItemWorker: SecurityItemWorker = {
let worker = SecurityItemWorker()
worker.service = self.dataSource?.keychainService?(for: self)
Expand All @@ -79,6 +83,7 @@ import Foundation
return worker
}()

/// An interface to the NSUbiquitousKeyValueStore.
lazy var ubiquitousWorker: UbiquitousWorker = {
return UbiquitousWorker()
}()
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a title="Classes Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="index.html">DataStoreManager Docs</a> (47% documented)</p>
<p><a href="index.html">DataStoreManager Docs</a> (52% documented)</p>
</div>
</header>
<div class="content-wrapper">
Expand Down
12 changes: 6 additions & 6 deletions docs/Classes/DataStoreManager.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a title="DataStoreManager Class Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html">DataStoreManager Docs</a> (47% documented)</p>
<p><a href="../index.html">DataStoreManager Docs</a> (52% documented)</p>
</div>
</header>
<div class="content-wrapper">
Expand Down Expand Up @@ -236,7 +236,7 @@ <h4>Declaration</h4>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Undocumented</p>
<p>An interface to the UserDefaults.</p>

</div>
<div class="declaration">
Expand All @@ -263,7 +263,7 @@ <h4>Declaration</h4>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Undocumented</p>
<p>An interface to the FileManager.</p>

</div>
<div class="declaration">
Expand All @@ -290,7 +290,7 @@ <h4>Declaration</h4>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Undocumented</p>
<p>An interface to the NSCache.</p>

</div>
<div class="declaration">
Expand All @@ -317,7 +317,7 @@ <h4>Declaration</h4>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Undocumented</p>
<p>An interface to the SecItem.</p>

</div>
<div class="declaration">
Expand All @@ -344,7 +344,7 @@ <h4>Declaration</h4>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Undocumented</p>
<p>An interface to the NSUbiquitousKeyValueStore.</p>

</div>
<div class="declaration">
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes/DataStoreManager/CacheWorker.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a title="CacheWorker Class Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../../index.html">DataStoreManager Docs</a> (47% documented)</p>
<p><a href="../../index.html">DataStoreManager Docs</a> (52% documented)</p>
</div>
</header>
<div class="content-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes/DataStoreManager/FileManagerWorker.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a title="FileManagerWorker Class Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../../index.html">DataStoreManager Docs</a> (47% documented)</p>
<p><a href="../../index.html">DataStoreManager Docs</a> (52% documented)</p>
</div>
</header>
<div class="content-wrapper">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a title="Directory Enumeration Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../../../index.html">DataStoreManager Docs</a> (47% documented)</p>
<p><a href="../../../index.html">DataStoreManager Docs</a> (52% documented)</p>
</div>
</header>
<div class="content-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes/DataStoreManager/SecurityItemWorker.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a title="SecurityItemWorker Class Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../../index.html">DataStoreManager Docs</a> (47% documented)</p>
<p><a href="../../index.html">DataStoreManager Docs</a> (52% documented)</p>
</div>
</header>
<div class="content-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes/DataStoreManager/StorageType.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a title="StorageType Enumeration Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../../index.html">DataStoreManager Docs</a> (47% documented)</p>
<p><a href="../../index.html">DataStoreManager Docs</a> (52% documented)</p>
</div>
</header>
<div class="content-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes/DataStoreManager/UbiquitousWorker.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a title="UbiquitousWorker Class Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../../index.html">DataStoreManager Docs</a> (47% documented)</p>
<p><a href="../../index.html">DataStoreManager Docs</a> (52% documented)</p>
</div>
</header>
<div class="content-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes/DataStoreManager/UserDefaultsWorker.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a title="UserDefaultsWorker Class Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../../index.html">DataStoreManager Docs</a> (47% documented)</p>
<p><a href="../../index.html">DataStoreManager Docs</a> (52% documented)</p>
</div>
</header>
<div class="content-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion docs/Extensions.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a title="Extensions Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="index.html">DataStoreManager Docs</a> (47% documented)</p>
<p><a href="index.html">DataStoreManager Docs</a> (52% documented)</p>
</div>
</header>
<div class="content-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion docs/Extensions/Bool.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a title="Bool Extension Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html">DataStoreManager Docs</a> (47% documented)</p>
<p><a href="../index.html">DataStoreManager Docs</a> (52% documented)</p>
</div>
</header>
<div class="content-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion docs/Extensions/String.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a title="String Extension Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html">DataStoreManager Docs</a> (47% documented)</p>
<p><a href="../index.html">DataStoreManager Docs</a> (52% documented)</p>
</div>
</header>
<div class="content-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion docs/Extensions/UIImage.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a title="UIImage Extension Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html">DataStoreManager Docs</a> (47% documented)</p>
<p><a href="../index.html">DataStoreManager Docs</a> (52% documented)</p>
</div>
</header>
<div class="content-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion docs/Extensions/UInt16.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a title="UInt16 Extension Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html">DataStoreManager Docs</a> (47% documented)</p>
<p><a href="../index.html">DataStoreManager Docs</a> (52% documented)</p>
</div>
</header>
<div class="content-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion docs/Protocols.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a title="Protocols Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="index.html">DataStoreManager Docs</a> (47% documented)</p>
<p><a href="index.html">DataStoreManager Docs</a> (52% documented)</p>
</div>
</header>
<div class="content-wrapper">
Expand Down
Loading

0 comments on commit 43f0cb9

Please sign in to comment.