mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-16 14:06:53 +01:00
comment documentations
This commit is contained in:
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSAsynchronousDataTransaction` serves as the Objective-C bridging type for `AsynchronousDataTransaction`.
|
||||
|
||||
- SeeAlso: `AsynchronousDataTransaction`
|
||||
*/
|
||||
@objc
|
||||
public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSBaseDataTransaction` serves as the Objective-C bridging type for `BaseDataTransaction`.
|
||||
|
||||
- SeeAlso: `BaseDataTransaction`
|
||||
*/
|
||||
@objc
|
||||
public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSFetchClause` implement clauses used to configure `NSFetchRequest`s.
|
||||
|
||||
- SeeAlso: `FetchClause`
|
||||
*/
|
||||
@objc
|
||||
public protocol CSFetchClause {
|
||||
@@ -44,6 +46,8 @@ public protocol CSFetchClause {
|
||||
|
||||
/**
|
||||
The `CSQueryClause` implement clauses used to configure `NSFetchRequest`s.
|
||||
|
||||
- SeeAlso: `QueryClause`
|
||||
*/
|
||||
@objc
|
||||
public protocol CSQueryClause {
|
||||
@@ -57,6 +61,8 @@ public protocol CSQueryClause {
|
||||
|
||||
/**
|
||||
The `CSDeleteClause` implement clauses used to configure `NSFetchRequest`s.
|
||||
|
||||
- SeeAlso: `DeleteClause`
|
||||
*/
|
||||
@objc
|
||||
public protocol CSDeleteClause {
|
||||
|
||||
@@ -44,8 +44,10 @@ public extension CSCoreStore {
|
||||
}
|
||||
error: &error];
|
||||
```
|
||||
|
||||
- parameter storage: the `CSInMemoryStore` instance
|
||||
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `CSSetupResult` argument indicates the result. This closure is NOT executed if an error is thrown, but will be executed with a failure `CSSetupResult` result if an error occurs asynchronously.
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
- returns: an `NSProgress` instance if a migration has started. `nil` if no migrations are required or if `error` was set.
|
||||
*/
|
||||
public static func addInMemoryStorage(storage: CSInMemoryStore, completion: (CSSetupResult) -> Void, error: NSErrorPointer) -> NSProgress? {
|
||||
@@ -68,8 +70,10 @@ public extension CSCoreStore {
|
||||
}
|
||||
error: &error];
|
||||
```
|
||||
|
||||
- parameter storage: the `CSSQLiteStore` instance
|
||||
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `CSSetupResult` argument indicates the result. This closure is NOT executed if an error is thrown, but will be executed with a failure `CSSetupResult` result if an error occurs asynchronously. Note that the `CSLocalStorage` associated to the `-[CSSetupResult storage]` may not always be the same instance as the parameter argument if a previous `CSLocalStorage` was already added at the same URL and with the same configuration.
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
- returns: an `NSProgress` instance if a migration has started. `nil` if no migrations are required or if `error` was set.
|
||||
*/
|
||||
public static func addSQLiteStorage(storage: CSSQLiteStore, completion: (CSSetupResult) -> Void, error: NSErrorPointer) -> NSProgress? {
|
||||
@@ -82,6 +86,7 @@ public extension CSCoreStore {
|
||||
|
||||
- parameter storage: the `CSSQLiteStore` instance
|
||||
- parameter completion: the closure to be executed on the main queue when the migration completes, either due to success or failure. The closure's `CSMigrationResult` argument indicates the result. This closure is NOT executed if an error is thrown, but will be executed with a failure `CSSetupResult` result if an error occurs asynchronously.
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
- returns: an `NSProgress` instance if a migration has started. `nil` if no migrations are required or if `error` was set.
|
||||
*/
|
||||
@objc
|
||||
@@ -94,6 +99,7 @@ public extension CSCoreStore {
|
||||
Checks the migration steps required for the `CSSQLiteStore` to match the `defaultStack`'s managed object model version.
|
||||
|
||||
- parameter storage: the `CSSQLiteStore` instance
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
- returns: a `CSMigrationType` array indicating the migration steps required for the store, or an empty array if the file does not exist yet. Otherwise, `nil` is returned and the `error` argument is set if either inspection of the store failed, or if no mapping model was found/inferred.
|
||||
*/
|
||||
@objc
|
||||
|
||||
@@ -51,6 +51,7 @@ public extension CSCoreStore {
|
||||
|
||||
/**
|
||||
Returns the entity class for the given entity name from the `defaultStack`'s model.
|
||||
|
||||
- parameter name: the entity name
|
||||
- returns: the `NSManagedObject` class for the given entity name, or `nil` if not found
|
||||
*/
|
||||
@@ -75,6 +76,7 @@ public extension CSCoreStore {
|
||||
CSSQLiteStore *storage = [CSCoreStore addInMemoryStorageAndWaitAndReturnError:&error];
|
||||
```
|
||||
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
- returns: the `CSInMemoryStore` added to the `defaultStack`
|
||||
*/
|
||||
@objc
|
||||
@@ -89,6 +91,7 @@ public extension CSCoreStore {
|
||||
CSSQLiteStore *storage = [CSCoreStore addSQLiteStorageAndWaitAndReturnError:&error];
|
||||
```
|
||||
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
- returns: the `CSSQLiteStore` added to the `defaultStack`
|
||||
*/
|
||||
@objc
|
||||
@@ -107,6 +110,7 @@ public extension CSCoreStore {
|
||||
```
|
||||
|
||||
- parameter storage: the `CSInMemoryStore`
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
- returns: the `CSInMemoryStore` added to the `defaultStack`
|
||||
*/
|
||||
@objc
|
||||
@@ -125,6 +129,7 @@ public extension CSCoreStore {
|
||||
```
|
||||
|
||||
- parameter storage: the `CSSQLiteStore`
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
- returns: the `CSSQLiteStore` added to the `defaultStack`
|
||||
*/
|
||||
@objc
|
||||
|
||||
@@ -30,14 +30,17 @@ import Foundation
|
||||
|
||||
/**
|
||||
The `CSCoreStore` serves as the Objective-C bridging type for `CoreStore`.
|
||||
|
||||
- SeeAlso: `CoreStore`
|
||||
*/
|
||||
@objc
|
||||
public final class CSCoreStore: NSObject {
|
||||
|
||||
/**
|
||||
The default `CSDataStack` instance to be used. If `defaultStack` is not set before the first time accessed, a default-configured `DataStack` will be created.
|
||||
The default `CSDataStack` instance to be used. If `defaultStack` is not set before the first time accessed, a default-configured `CSDataStack` will be created.
|
||||
|
||||
Changing the `defaultStack` is thread safe, but it is recommended to setup stacks on a common queue (e.g. the main queue).
|
||||
- SeeAlso: `CSDataStack`
|
||||
- Note: Changing the `defaultStack` is thread safe, but it is recommended to setup `CSDataStacks` on a common queue (e.g. the main queue).
|
||||
*/
|
||||
@objc
|
||||
public static var defaultStack: CSDataStack {
|
||||
|
||||
@@ -44,8 +44,10 @@ public extension CSDataStack {
|
||||
}
|
||||
error: &error];
|
||||
```
|
||||
|
||||
- parameter storage: the `CSInMemoryStore` instance
|
||||
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `CSSetupResult` argument indicates the result. This closure is NOT executed if an error is thrown, but will be executed with a failure `CSSetupResult` result if an error occurs asynchronously.
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
- returns: an `NSProgress` instance if a migration has started. `nil` if no migrations are required or if `error` was set.
|
||||
*/
|
||||
@objc
|
||||
@@ -75,8 +77,10 @@ public extension CSDataStack {
|
||||
}
|
||||
error: &error];
|
||||
```
|
||||
|
||||
- parameter storage: the `CSSQLiteStore` instance
|
||||
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `CSSetupResult` argument indicates the result. This closure is NOT executed if an error is thrown, but will be executed with a failure `CSSetupResult` result if an error occurs asynchronously. Note that the `CSLocalStorage` associated to the `-[CSSetupResult storage]` may not always be the same instance as the parameter argument if a previous `CSLocalStorage` was already added at the same URL and with the same configuration.
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
- returns: an `NSProgress` instance if a migration has started. `nil` if no migrations are required or if `error` was set.
|
||||
*/
|
||||
@objc
|
||||
@@ -96,6 +100,7 @@ public extension CSDataStack {
|
||||
|
||||
- parameter storage: the `CSSQLiteStore` instance
|
||||
- parameter completion: the closure to be executed on the main queue when the migration completes, either due to success or failure. The closure's `CSMigrationResult` argument indicates the result. This closure is NOT executed if an error is thrown, but will be executed with a failure `CSSetupResult` result if an error occurs asynchronously.
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
- returns: an `NSProgress` instance if a migration has started. `nil` if no migrations are required or if `error` was set.
|
||||
*/
|
||||
@objc
|
||||
@@ -114,6 +119,7 @@ public extension CSDataStack {
|
||||
Checks the migration steps required for the `CSSQLiteStore` to match the `CSDataStack`'s managed object model version.
|
||||
|
||||
- parameter storage: the `CSSQLiteStore` instance
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
- returns: a `CSMigrationType` array indicating the migration steps required for the store, or an empty array if the file does not exist yet. Otherwise, `nil` is returned and the `error` argument is set if either inspection of the store failed, or if no mapping model was found/inferred.
|
||||
*/
|
||||
@objc
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSDataStack` serves as the Objective-C bridging type for `DataStack`.
|
||||
|
||||
- SeeAlso: `DataStack`
|
||||
*/
|
||||
@objc
|
||||
public final class CSDataStack: NSObject, CoreStoreObjectiveCType {
|
||||
@@ -160,6 +162,7 @@ public final class CSDataStack: NSObject, CoreStoreObjectiveCType {
|
||||
CSSQLiteStore *storage = [dataStack addInMemoryStorageAndWaitAndReturnError:&error];
|
||||
```
|
||||
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
- returns: the `CSInMemoryStore` added to the stack
|
||||
*/
|
||||
@objc
|
||||
@@ -177,6 +180,7 @@ public final class CSDataStack: NSObject, CoreStoreObjectiveCType {
|
||||
CSSQLiteStore *storage = [dataStack addSQLiteStorageAndWaitAndReturnError:&error];
|
||||
```
|
||||
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
- returns: the `CSSQLiteStore` added to the stack
|
||||
*/
|
||||
@objc
|
||||
@@ -198,6 +202,7 @@ public final class CSDataStack: NSObject, CoreStoreObjectiveCType {
|
||||
```
|
||||
|
||||
- parameter storage: the `CSInMemoryStore`
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
- returns: the `CSInMemoryStore` added to the stack
|
||||
*/
|
||||
@objc
|
||||
@@ -219,6 +224,7 @@ public final class CSDataStack: NSObject, CoreStoreObjectiveCType {
|
||||
```
|
||||
|
||||
- parameter storage: the `CSSQLiteStore`
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
- returns: the `CSSQLiteStore` added to the stack
|
||||
*/
|
||||
@objc
|
||||
|
||||
@@ -30,13 +30,17 @@ import CoreData
|
||||
// MARK: - CSError
|
||||
|
||||
/**
|
||||
The `CSError` provides a facade for global CoreStore error declarations.
|
||||
All errors thrown from CoreStore are expressed in `CSError`s.
|
||||
|
||||
- SeeAlso: `CoreStoreError`
|
||||
*/
|
||||
@objc
|
||||
public final class CSError: NSError, CoreStoreObjectiveCType {
|
||||
|
||||
/**
|
||||
The `NSError` error domain for `CSCoreStore`.
|
||||
The `NSError` error domain for `CSError`.
|
||||
|
||||
- SeeAlso: `CoreStoreErrorErrorDomain`
|
||||
*/
|
||||
@objc
|
||||
public static let errorDomain = CoreStoreErrorDomain
|
||||
@@ -61,8 +65,6 @@ public final class CSError: NSError, CoreStoreObjectiveCType {
|
||||
|
||||
// MARK: CoreStoreObjectiveCType
|
||||
|
||||
private var swiftError: CoreStoreError?
|
||||
|
||||
public var bridgeToSwift: CoreStoreError {
|
||||
|
||||
if let swift = self.swiftError {
|
||||
@@ -174,6 +176,11 @@ public final class CSError: NSError, CoreStoreObjectiveCType {
|
||||
|
||||
super.init(coder: aDecoder)
|
||||
}
|
||||
|
||||
|
||||
// MARK: Private
|
||||
|
||||
private var swiftError: CoreStoreError?
|
||||
}
|
||||
|
||||
|
||||
@@ -181,6 +188,9 @@ public final class CSError: NSError, CoreStoreObjectiveCType {
|
||||
|
||||
/**
|
||||
The `NSError` error codes for `CSError.Domain`.
|
||||
|
||||
- SeeAlso: `CSError`
|
||||
- SeeAlso: `CoreStoreError`
|
||||
*/
|
||||
@objc
|
||||
public enum CSErrorCode: Int {
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSFrom` serves as the Objective-C bridging type for `From`.
|
||||
|
||||
- SeeAlso: `From`
|
||||
*/
|
||||
@objc
|
||||
public final class CSFrom: NSObject, CoreStoreObjectiveCType {
|
||||
@@ -40,6 +42,7 @@ public final class CSFrom: NSObject, CoreStoreObjectiveCType {
|
||||
```
|
||||
MyPersonEntity *people = [transaction fetchAllFrom:[CSFrom entityClass:[MyPersonEntity class]]];
|
||||
```
|
||||
|
||||
- parameter entityClass: the `NSManagedObject` class type to be created
|
||||
- returns: a `CSFrom` clause with the specified entity class
|
||||
*/
|
||||
@@ -54,6 +57,7 @@ public final class CSFrom: NSObject, CoreStoreObjectiveCType {
|
||||
```
|
||||
MyPersonEntity *people = [transaction fetchAllFrom:[CSFrom entityClass:[MyPersonEntity class] configuration:@"Configuration1"]];
|
||||
```
|
||||
|
||||
- parameter configuration: the `NSPersistentStore` configuration name to associate objects from. This parameter is required if multiple configurations contain the created `NSManagedObject`'s entity type. Set to `nil` to use the default configuration.
|
||||
- parameter otherConfigurations: an optional list of other configuration names to associate objects from (see `configuration` parameter)
|
||||
- returns: a `CSFrom` clause with the specified configurations
|
||||
@@ -69,6 +73,7 @@ public final class CSFrom: NSObject, CoreStoreObjectiveCType {
|
||||
```
|
||||
MyPersonEntity *people = [transaction fetchAllFrom:[CSFrom entityClass:[MyPersonEntity class] configurations:@[[NSNull null], @"Configuration1"]]];
|
||||
```
|
||||
|
||||
- parameter entity: the associated `NSManagedObject` entity class
|
||||
- parameter configurations: a list of `NSPersistentStore` configuration names to associate objects from. This parameter is required if multiple configurations contain the created `NSManagedObject`'s entity type. Set to `[NSNull null]` to use the default configuration.
|
||||
- returns: a `CSFrom` clause with the specified configurations
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSGroupBy` serves as the Objective-C bridging type for `GroupBy`.
|
||||
|
||||
- SeeAlso: `GroupBy`
|
||||
*/
|
||||
@objc
|
||||
public final class CSGroupBy: NSObject, CSQueryClause, CoreStoreObjectiveCType {
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSInMemoryStore` serves as the Objective-C bridging type for `InMemoryStore`.
|
||||
|
||||
- SeeAlso: `InMemoryStore`
|
||||
*/
|
||||
@objc
|
||||
public final class CSInMemoryStore: NSObject, CSStorageInterface, CoreStoreObjectiveCType {
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSInto` serves as the Objective-C bridging type for `Into<T>`.
|
||||
|
||||
- SeeAlso: `Into`
|
||||
*/
|
||||
@objc
|
||||
public final class CSInto: NSObject, CoreStoreObjectiveCType {
|
||||
@@ -40,6 +42,7 @@ public final class CSInto: NSObject, CoreStoreObjectiveCType {
|
||||
```
|
||||
MyPersonEntity *person = [transaction createInto:[CSInto entityClass:[MyPersonEntity class]]];
|
||||
```
|
||||
|
||||
- parameter entityClass: the `NSManagedObject` class type to be created
|
||||
- returns: a `CSInto` clause with the specified entity class
|
||||
*/
|
||||
@@ -54,6 +57,7 @@ public final class CSInto: NSObject, CoreStoreObjectiveCType {
|
||||
```
|
||||
MyPersonEntity *person = [transaction createInto:[CSInto entityClass:[MyPersonEntity class]]];
|
||||
```
|
||||
|
||||
- parameter entityClass: the `NSManagedObject` class type to be created
|
||||
- parameter configuration: the `NSPersistentStore` configuration name to associate the object to. This parameter is required if multiple configurations contain the created `NSManagedObject`'s entity type. Set to `nil` to use the default configuration.
|
||||
- returns: a `CSInto` clause with the specified configuration
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSListMonitor` serves as the Objective-C bridging type for `ListMonitor<T>`.
|
||||
|
||||
- SeeAlso: `ListMonitor`
|
||||
*/
|
||||
@available(OSX, unavailable)
|
||||
@objc
|
||||
|
||||
@@ -37,6 +37,8 @@ import CoreData
|
||||
fetchClauses:@[[CSOrderBy sortDescriptor:[CSSortKey withKeyPath:@"lastName" ascending:YES]]]];
|
||||
[monitor addListObserver:self];
|
||||
```
|
||||
|
||||
- SeeAlso: `ListObserver`
|
||||
*/
|
||||
@available(OSX, unavailable)
|
||||
@objc
|
||||
@@ -86,6 +88,8 @@ public protocol CSListObserver: class, AnyObject {
|
||||
fetchClauses:@[[CSOrderBy sortDescriptor:[CSSortKey withKeyPath:@"lastName" ascending:YES]]]];
|
||||
[monitor addListObjectObserver:self];
|
||||
```
|
||||
|
||||
- SeeAlso: `ListObjectObserver`
|
||||
*/
|
||||
@available(OSX, unavailable)
|
||||
@objc
|
||||
@@ -145,6 +149,8 @@ public protocol CSListObjectObserver: CSListObserver {
|
||||
fetchClauses:@[[CSOrderBy sortDescriptor:[CSSortKey withKeyPath:@"lastName" ascending:YES]]]];
|
||||
[monitor addListSectionObserver:self];
|
||||
```
|
||||
|
||||
- SeeAlso: `ListSectionObserver`
|
||||
*/
|
||||
@available(OSX, unavailable)
|
||||
@objc
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSMigrationResult` serves as the Objective-C bridging type for `MigrationResult`.
|
||||
|
||||
- SeeAlso: `MigrationResult`
|
||||
*/
|
||||
@objc
|
||||
public final class CSMigrationResult: NSObject, CoreStoreObjectiveCType {
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSMigrationType` serves as the Objective-C bridging type for `MigrationType`.
|
||||
|
||||
- SeeAlso: `MigrationType`
|
||||
*/
|
||||
@objc
|
||||
public final class CSMigrationType: NSObject, CoreStoreObjectiveCType {
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSObjectMonitor` serves as the Objective-C bridging type for `ObjectMonitor<T>`.
|
||||
|
||||
- SeeAlso: `ObjectMonitor`
|
||||
*/
|
||||
@available(OSX, unavailable)
|
||||
@objc
|
||||
|
||||
@@ -35,6 +35,8 @@ import CoreData
|
||||
CSObjectMonitor *monitor = [CSCoreStore monitorObject:myObject];
|
||||
[monitor addObjectObserver:self];
|
||||
```
|
||||
|
||||
- SeeAlso: `ObjectObserver`
|
||||
*/
|
||||
@available(OSX, unavailable)
|
||||
@objc
|
||||
|
||||
@@ -31,6 +31,9 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSSortKey` is a syntax-sugar class for `NSSortDescriptor` meant to be used with `CSOrderBy`.
|
||||
|
||||
- SeeAlso: `CSOrderBy`
|
||||
- SeeAlso: `SortKey`
|
||||
*/
|
||||
@objc
|
||||
public final class CSSortKey: NSSortDescriptor {
|
||||
@@ -54,6 +57,8 @@ public final class CSSortKey: NSSortDescriptor {
|
||||
|
||||
/**
|
||||
The `CSOrderBy` serves as the Objective-C bridging type for `OrderBy`.
|
||||
|
||||
- SeeAlso: `OrderBy`
|
||||
*/
|
||||
@objc
|
||||
public final class CSOrderBy: NSObject, CSFetchClause, CSQueryClause, CSDeleteClause, CoreStoreObjectiveCType {
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSSQLiteStore` serves as the Objective-C bridging type for `SQLiteStore`.
|
||||
|
||||
- SeeAlso: `SQLiteStore`
|
||||
*/
|
||||
@objc
|
||||
public final class CSSQLiteStore: NSObject, CSLocalStorage, CoreStoreObjectiveCType {
|
||||
@@ -58,8 +60,8 @@ public final class CSSQLiteStore: NSObject, CSLocalStorage, CoreStoreObjectiveCT
|
||||
|
||||
/**
|
||||
Initializes an SQLite store interface from the given SQLite file name. When this instance is passed to the `CSDataStack`'s `-addStorage*:` methods, a new SQLite file will be created if it does not exist.
|
||||
- Warning: The default SQLite file location for the `CSLegacySQLiteStore` and `CSSQLiteStore` are different. If the app was depending on CoreStore's default directories prior to 2.0.0, make sure to use `CSLegacySQLiteStore` instead of `CSSQLiteStore`.
|
||||
|
||||
- Warning: The default SQLite file location for the `CSLegacySQLiteStore` and `CSSQLiteStore` are different. If the app was depending on CoreStore's default directories prior to 2.0.0, make sure to use `CSLegacySQLiteStore` instead of `CSSQLiteStore`.
|
||||
- parameter fileName: the local filename for the SQLite persistent store in the "Application Support/<bundle id>" directory (or the "Caches/<bundle id>" directory on tvOS). Note that if you have multiple configurations, you will need to specify a different `fileName` explicitly for each of them.
|
||||
- parameter configuration: an optional configuration name from the model file. If not specified, defaults to `nil`, the "Default" configuration. Note that if you have multiple configurations, you will need to specify a different `fileName` explicitly for each of them.
|
||||
- parameter mappingModelBundles: a list of `NSBundle`s from which to search mapping models for migration
|
||||
@@ -80,6 +82,7 @@ public final class CSSQLiteStore: NSObject, CSLocalStorage, CoreStoreObjectiveCT
|
||||
|
||||
/**
|
||||
Initializes an `CSSQLiteStore` with an all-default settings: a `fileURL` pointing to a "<Application name>.sqlite" file in the "Application Support/<bundle id>" directory (or the "Caches/<bundle id>" directory on tvOS), a `nil` `configuration` pertaining to the "Default" configuration, a `mappingModelBundles` set to search all `NSBundle`s, and `localStorageOptions` set to `.AllowProgresiveMigration`.
|
||||
|
||||
- Warning: The default SQLite file location for the `CSLegacySQLiteStore` and `CSSQLiteStore` are different. If the app was depending on CoreStore's default directories prior to 2.0.0, make sure to use `CSLegacySQLiteStore` instead of `CSSQLiteStore`.
|
||||
*/
|
||||
@objc
|
||||
@@ -151,9 +154,9 @@ public final class CSSQLiteStore: NSObject, CSLocalStorage, CoreStoreObjectiveCT
|
||||
Called by the `CSDataStack` to perform actual deletion of the store file from disk. Do not call directly! The `sourceModel` argument is a hint for the existing store's model version. For `CSSQLiteStore`, this converts the database's WAL journaling mode to DELETE before deleting the file.
|
||||
*/
|
||||
@objc
|
||||
public func eraseStorageAndWait(soureModel soureModel: NSManagedObjectModel) throws {
|
||||
public func eraseStorageAndWait(soureModel soureModel: NSManagedObjectModel, error: NSErrorPointer) -> Bool {
|
||||
|
||||
try bridge {
|
||||
return bridge(error) {
|
||||
|
||||
try self.bridgeToSwift.eraseStorageAndWait(soureModel: soureModel)
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSSaveResult` serves as the Objective-C bridging type for `SaveResult`.
|
||||
|
||||
- SeeAlso: `SaveResult`
|
||||
*/
|
||||
@objc
|
||||
public final class CSSaveResult: NSObject, CoreStoreObjectiveCType {
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSSectionBy` serves as the Objective-C bridging type for `SectionBy`.
|
||||
|
||||
- SeeAlso: `SectionBy`
|
||||
*/
|
||||
@available(OSX, unavailable)
|
||||
@objc
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSSelectTerm` serves as the Objective-C bridging type for `SelectTerm`.
|
||||
|
||||
- SeeAlso: `SelectTerm`
|
||||
*/
|
||||
@objc
|
||||
public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
@@ -43,6 +45,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
select:[CSSelect stringForTerm:[CSSelectTerm attribute:@"fullName"]]
|
||||
fetchClauses:@[[CSWhere keyPath:@"employeeID" isEqualTo: @1111]]];
|
||||
```
|
||||
|
||||
- parameter keyPath: the attribute name
|
||||
- returns: a `CSSelectTerm` to a `CSSelect` clause for querying an entity attribute
|
||||
*/
|
||||
@@ -58,6 +61,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
queryValueFrom:[CSFrom entityClass:[MyPersonEntity class]]
|
||||
select:[CSSelect numberForTerm:[CSSelectTerm average:@"age" as:nil]]];
|
||||
```
|
||||
|
||||
- parameter keyPath: the attribute name
|
||||
- parameter `as`: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "average(<attributeName>)" is used
|
||||
- returns: a `CSSelectTerm` to a `CSSelect` clause for querying the average value of an attribute
|
||||
@@ -74,6 +78,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
queryValueFrom:[CSFrom entityClass:[MyPersonEntity class]]
|
||||
select:[CSSelect numberForTerm:[CSSelectTerm count:@"employeeID" as:nil]]];
|
||||
```
|
||||
|
||||
- parameter keyPath: the attribute name
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "count(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for a count query
|
||||
@@ -90,6 +95,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
queryValueFrom:[CSFrom entityClass:[MyPersonEntity class]]
|
||||
select:[CSSelect numberForTerm:[CSSelectTerm maximum:@"age" as:nil]]];
|
||||
```
|
||||
|
||||
- parameter keyPath: the attribute name
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "max(<attributeName>)" is used
|
||||
- returns: a `CSSelectTerm` to a `CSSelect` clause for querying the maximum value for an attribute
|
||||
@@ -106,6 +112,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
queryValueFrom:[CSFrom entityClass:[MyPersonEntity class]]
|
||||
select:[CSSelect numberForTerm:[CSSelectTerm minimum:@"age" as:nil]]];
|
||||
```
|
||||
|
||||
- parameter keyPath: the attribute name
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "min(<attributeName>)" is used
|
||||
- returns: a `CSSelectTerm` to a `CSSelect` clause for querying the minimum value for an attribute
|
||||
@@ -122,6 +129,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
queryValueFrom:[CSFrom entityClass:[MyPersonEntity class]]
|
||||
select:[CSSelect numberForTerm:[CSSelectTerm sum:@"age" as:nil]]];
|
||||
```
|
||||
|
||||
- parameter keyPath: the attribute name
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "sum(<attributeName>)" is used
|
||||
- returns: a `CSSelectTerm` to a `CSSelect` clause for querying the sum value for an attribute
|
||||
@@ -138,13 +146,8 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
||||
queryValueFrom:[CSFrom entityClass:[MyPersonEntity class]]
|
||||
select:[CSSelect objectIDForTerm:[CSSelectTerm objectIDAs:nil]]
|
||||
fetchClauses:@[[CSWhere keyPath:@"employeeID" isEqualTo: @1111]]];
|
||||
|
||||
let objectID = CoreStore.queryValue(
|
||||
From(MyPersonEntity),
|
||||
Select<NSManagedObjectID>(.ObjectID()),
|
||||
Where("employeeID", isEqualTo: 1111)
|
||||
)
|
||||
```
|
||||
|
||||
- parameter keyPath: the attribute name
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "objecID" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
|
||||
@@ -202,6 +205,8 @@ extension SelectTerm: CoreStoreSwiftType {
|
||||
|
||||
/**
|
||||
The `CSSelect` serves as the Objective-C bridging type for `Select`.
|
||||
|
||||
- SeeAlso: `Select`
|
||||
*/
|
||||
@objc
|
||||
public final class CSSelect: NSObject {
|
||||
@@ -213,6 +218,7 @@ public final class CSSelect: NSObject {
|
||||
queryValueFrom:[CSFrom entityClass:[MyPersonEntity class]]
|
||||
select:[CSSelect numberForTerm:[CSSelectTerm maximum:@"age" as:nil]]];
|
||||
```
|
||||
|
||||
- parameter term: the `CSSelectTerm` specifying the attribute/aggregate value to query
|
||||
- returns: a `CSSelect` clause for querying an entity attribute
|
||||
*/
|
||||
@@ -228,6 +234,7 @@ public final class CSSelect: NSObject {
|
||||
queryValueFrom:[CSFrom entityClass:[MyPersonEntity class]]
|
||||
select:[CSSelect decimalNumberForTerm:[CSSelectTerm average:@"age" as:nil]]];
|
||||
```
|
||||
|
||||
- parameter term: the `CSSelectTerm` specifying the attribute/aggregate value to query
|
||||
- returns: a `CSSelect` clause for querying an entity attribute
|
||||
*/
|
||||
@@ -244,6 +251,7 @@ public final class CSSelect: NSObject {
|
||||
select:[CSSelect stringForTerm:[CSSelectTerm attribute:@"fullName"]]
|
||||
fetchClauses:@[[CSWhere keyPath:@"employeeID" isEqualTo: @1111]]];
|
||||
```
|
||||
|
||||
- parameter term: the `CSSelectTerm` specifying the attribute/aggregate value to query
|
||||
- returns: a `CSSelect` clause for querying an entity attribute
|
||||
*/
|
||||
@@ -259,6 +267,7 @@ public final class CSSelect: NSObject {
|
||||
queryValueFrom:[CSFrom entityClass:[MyPersonEntity class]]
|
||||
select:[CSSelect dateForTerm:[CSSelectTerm maximum:@"updatedDate" as:nil]]];
|
||||
```
|
||||
|
||||
- parameter term: the `CSSelectTerm` specifying the attribute/aggregate value to query
|
||||
- returns: a `CSSelect` clause for querying an entity attribute
|
||||
*/
|
||||
@@ -275,6 +284,7 @@ public final class CSSelect: NSObject {
|
||||
select:[CSSelect dataForTerm:[CSSelectTerm attribute:@"imageData" as:nil]]
|
||||
fetchClauses:@[[CSWhere keyPath:@"employeeID" isEqualTo: @1111]]];
|
||||
```
|
||||
|
||||
- parameter term: the `CSSelectTerm` specifying the attribute/aggregate value to query
|
||||
- returns: a `CSSelect` clause for querying an entity attribute
|
||||
*/
|
||||
@@ -291,6 +301,7 @@ public final class CSSelect: NSObject {
|
||||
select:[CSSelect objectID]
|
||||
fetchClauses:@[[CSWhere keyPath:@"employeeID" isEqualTo: @1111]]];
|
||||
```
|
||||
|
||||
- parameter term: the `CSSelectTerm` specifying the attribute/aggregate value to query
|
||||
- returns: a `CSSelect` clause for querying an entity attribute
|
||||
*/
|
||||
@@ -306,6 +317,7 @@ public final class CSSelect: NSObject {
|
||||
queryValueFrom:[CSFrom entityClass:[MyPersonEntity class]]
|
||||
select:[CSSelect dictionaryForTerm:[CSSelectTerm maximum:@"age" as:nil]]];
|
||||
```
|
||||
|
||||
- parameter term: the `CSSelectTerm` specifying the attribute/aggregate value to query
|
||||
- returns: a `CSSelect` clause for querying an entity attribute
|
||||
*/
|
||||
@@ -314,6 +326,20 @@ public final class CSSelect: NSObject {
|
||||
return self.init(Select<NSDictionary>(term.bridgeToSwift))
|
||||
}
|
||||
|
||||
/**
|
||||
Creates a `CSSelect` clause for querying `NSDictionary` of an entity's attribute keys and values.
|
||||
```
|
||||
NSDictionary *keyValues = [CSCoreStore
|
||||
queryValueFrom:[CSFrom entityClass:[MyPersonEntity class]]
|
||||
select:[CSSelect dictionaryForTerms:@[
|
||||
[CSSelectTerm attribute:@"name" as:nil],
|
||||
[CSSelectTerm attribute:@"age" as:nil]
|
||||
]]];
|
||||
```
|
||||
|
||||
- parameter terms: the `CSSelectTerm`s specifying the attribute/aggregate values to query
|
||||
- returns: a `CSSelect` clause for querying an entity attribute
|
||||
*/
|
||||
public static func dictionaryForTerms(terms: [CSSelectTerm]) -> CSSelect {
|
||||
|
||||
return self.init(Select<NSDictionary>(terms.map { $0.bridgeToSwift }))
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSSetupResult` serves as the Objective-C bridging type for `SetupResult`.
|
||||
|
||||
- SeeAlso: `SetupResult`
|
||||
*/
|
||||
@objc
|
||||
public final class CSSetupResult: NSObject {
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSStorageInterface` serves as the Objective-C bridging type for `StorageInterface`.
|
||||
|
||||
- SeeAlso: `StorageInterface`
|
||||
*/
|
||||
@objc
|
||||
public protocol CSStorageInterface {
|
||||
@@ -59,6 +61,8 @@ public protocol CSStorageInterface {
|
||||
|
||||
/**
|
||||
The `CSLocalStorageOptions` provides settings that tells the `CSDataStack` how to setup the persistent store for `CSLocalStorage` implementers.
|
||||
|
||||
- SeeAlso: `LocalStorageOptions`
|
||||
*/
|
||||
@objc
|
||||
public enum CSLocalStorageOptions: Int {
|
||||
@@ -89,6 +93,8 @@ public enum CSLocalStorageOptions: Int {
|
||||
|
||||
/**
|
||||
The `CSLocalStorage` serves as the Objective-C bridging type for `LocalStorage`.
|
||||
|
||||
- SeeAlso: `LocalStorage`
|
||||
*/
|
||||
@objc
|
||||
public protocol CSLocalStorage: CSStorageInterface {
|
||||
@@ -115,5 +121,5 @@ public protocol CSLocalStorage: CSStorageInterface {
|
||||
Called by the `CSDataStack` to perform actual deletion of the store file from disk. Do not call directly! The `sourceModel` argument is a hint for the existing store's model version. Implementers can use the `sourceModel` to perform necessary store operations. (SQLite stores for example, can convert WAL journaling mode to DELETE before deleting)
|
||||
*/
|
||||
@objc
|
||||
func eraseStorageAndWait(soureModel soureModel: NSManagedObjectModel) throws
|
||||
func eraseStorageAndWait(soureModel soureModel: NSManagedObjectModel, error: NSErrorPointer) -> Bool
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSSynchronousDataTransaction` serves as the Objective-C bridging type for `SynchronousDataTransaction`.
|
||||
|
||||
- SeeAlso: `SynchronousDataTransaction`
|
||||
*/
|
||||
@objc
|
||||
public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSTweak` serves as the Objective-C bridging type for `Tweak`.
|
||||
|
||||
- SeeAlso: `Tweak`
|
||||
*/
|
||||
@objc
|
||||
public final class CSTweak: NSObject, CSFetchClause, CSQueryClause, CSDeleteClause, CoreStoreObjectiveCType {
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSUnsafeDataTransaction` serves as the Objective-C bridging type for `UnsafeDataTransaction`.
|
||||
|
||||
- SeeAlso: `UnsafeDataTransaction`
|
||||
*/
|
||||
@objc
|
||||
public final class CSUnsafeDataTransaction: CSBaseDataTransaction {
|
||||
|
||||
@@ -31,6 +31,8 @@ import CoreData
|
||||
|
||||
/**
|
||||
The `CSWhere` serves as the Objective-C bridging type for `Where`.
|
||||
|
||||
- SeeAlso: `Where`
|
||||
*/
|
||||
@objc
|
||||
public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClause, CoreStoreObjectiveCType {
|
||||
|
||||
@@ -28,22 +28,43 @@ import Foundation
|
||||
|
||||
// MARK: - CoreStoreObjectiveCType
|
||||
|
||||
/**
|
||||
`CoreStoreObjectiveCType`s are Objective-C accessible classes that represent CoreStore's Swift types.
|
||||
*/
|
||||
public protocol CoreStoreObjectiveCType: class, AnyObject {
|
||||
|
||||
/**
|
||||
The corresponding Swift type
|
||||
*/
|
||||
associatedtype SwiftType
|
||||
|
||||
/**
|
||||
The bridged Swift instance
|
||||
*/
|
||||
var bridgeToSwift: SwiftType { get }
|
||||
|
||||
/**
|
||||
Initializes this instance with the Swift instance to bridge from
|
||||
*/
|
||||
init(_ swiftValue: SwiftType)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - CoreStoreSwiftType
|
||||
|
||||
/**
|
||||
`CoreStoreSwiftType`s are CoreStore's Swift types that are bridgeable to Objective-C.
|
||||
*/
|
||||
public protocol CoreStoreSwiftType {
|
||||
|
||||
/**
|
||||
The corresponding Objective-C type
|
||||
*/
|
||||
associatedtype ObjectiveCType
|
||||
|
||||
/**
|
||||
The bridged Objective-C instance
|
||||
*/
|
||||
var bridgeToObjectiveC: ObjectiveCType { get }
|
||||
}
|
||||
|
||||
@@ -107,6 +128,21 @@ internal func bridge<T: CoreStoreSwiftType>(error: NSErrorPointer, @noescape _ c
|
||||
}
|
||||
}
|
||||
|
||||
internal func bridge(error: NSErrorPointer, @noescape _ closure: () throws -> Void) -> Bool {
|
||||
|
||||
do {
|
||||
|
||||
try closure()
|
||||
error.memory = nil
|
||||
return true
|
||||
}
|
||||
catch let swiftError {
|
||||
|
||||
error.memory = swiftError.bridgeToObjectiveC
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
internal func bridge<T>(error: NSErrorPointer, @noescape _ closure: () throws -> T?) -> T? {
|
||||
|
||||
do {
|
||||
|
||||
@@ -33,7 +33,13 @@ import CoreData
|
||||
public extension NSFetchedResultsController {
|
||||
|
||||
/**
|
||||
Utility for creating an `NSFetchedResultsController` from a `CSDataStack`. This is useful when an `NSFetchedResultsController` is preferred over the overhead of `CSListMonitor`s abstraction.
|
||||
Utility for creating an `NSFetchedResultsController` from a `CSDataStack`. This is useful when an `NSFetchedResultsController` is preferred over the overhead of `CSListMonitor`s abstractio
|
||||
|
||||
- parameter dataStack: the `CSDataStack` to observe objects from
|
||||
- parameter fetchRequest: the `NSFetchRequest` instance to use with the `NSFetchedResultsController`
|
||||
- parameter from: an optional `CSFrom` clause indicating the entity type. If not specified, the `fetchRequest` argument's `entity` property should already be set.
|
||||
- parameter sectionBy: a `CSSectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
|
||||
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.
|
||||
*/
|
||||
@objc
|
||||
public static func cs_createForStack(dataStack: CSDataStack, fetchRequest: NSFetchRequest, from: CSFrom?, sectionBy: CSSectionBy?, fetchClauses: [CSFetchClause]) -> NSFetchedResultsController {
|
||||
|
||||
@@ -32,6 +32,7 @@ public extension NSProgress {
|
||||
|
||||
/**
|
||||
Sets a closure that the `NSProgress` calls whenever its `fractionCompleted` changes. You can use this instead of setting up KVO.
|
||||
|
||||
- parameter closure: the closure to execute on progress change
|
||||
*/
|
||||
@objc
|
||||
|
||||
Reference in New Issue
Block a user