WIP: broken generics

This commit is contained in:
John Estropia
2016-09-06 20:16:46 +09:00
parent b502895d63
commit 82de482191
95 changed files with 610 additions and 677 deletions

View File

@@ -38,10 +38,10 @@ public extension NSManagedObject {
- returns: the primitive value for the KVC key
*/
@nonobjc
public func accessValueForKVCKey(_ KVCKey: KeyPath) -> AnyObject? {
public func accessValueForKVCKey(_ KVCKey: KeyPath) -> Any? {
self.willAccessValue(forKey: KVCKey)
let primitiveValue: AnyObject? = self.primitiveValue(forKey: KVCKey)
let primitiveValue: Any? = self.primitiveValue(forKey: KVCKey)
self.didAccessValue(forKey: KVCKey)
return primitiveValue
@@ -54,7 +54,7 @@ public extension NSManagedObject {
- parameter KVCKey: the KVC key
*/
@nonobjc
public func setValue(_ value: AnyObject?, forKVCKey KVCKey: KeyPath) {
public func setValue(_ value: Any?, forKVCKey KVCKey: KeyPath) {
self.willChangeValue(forKey: KVCKey)
self.setPrimitiveValue(value, forKey: KVCKey)

View File

@@ -79,7 +79,8 @@ public extension Progress {
private final class ProgressObserver: NSObject {
private unowned let progress: Progress
private var progressHandler: ((_ progress: Progress) -> Void)? {
fileprivate var progressHandler: ((_ progress: Progress) -> Void)? {
didSet {
@@ -105,7 +106,7 @@ private final class ProgressObserver: NSObject {
}
}
private init(_ progress: Progress) {
fileprivate init(_ progress: Progress) {
self.progress = progress
super.init()
@@ -120,7 +121,7 @@ private final class ProgressObserver: NSObject {
}
}
override func observeValue(forKeyPath keyPath: String?, of object: AnyObject?, change: [NSKeyValueChangeKey : AnyObject]?, context: UnsafeMutablePointer<Void>?) {
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
guard let progress = object as? Progress,
progress == self.progress,
@@ -131,7 +132,7 @@ private final class ProgressObserver: NSObject {
DispatchQueue.main.async { [weak self] () -> Void in
self?.progressHandler?(progress: progress)
self?.progressHandler?(progress)
}
}
}

View File

@@ -316,7 +316,7 @@ public extension BaseDataTransaction {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/
public func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[NSString: AnyObject]]? {
public func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
CoreStore.assert(
self.isRunningInAllowedQueue(),
@@ -336,7 +336,7 @@ public extension BaseDataTransaction {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/
public func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[NSString: AnyObject]]? {
public func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
CoreStore.assert(
self.isRunningInAllowedQueue(),

View File

@@ -115,10 +115,10 @@ public struct OrderBy: FetchClause, QueryClause, DeleteClause, Hashable {
switch sortKey {
case .ascending(let keyPath):
return SortDescriptor(key: keyPath, ascending: true)
return NSSortDescriptor(key: keyPath, ascending: true)
case .descending(let keyPath):
return SortDescriptor(key: keyPath, ascending: false)
return NSSortDescriptor(key: keyPath, ascending: false)
}
}
)

View File

@@ -44,7 +44,7 @@ public protocol SelectValueResultType: SelectResultType {
static var attributeType: NSAttributeType { get }
static func fromResultObject(_ result: AnyObject) -> Self?
static func fromResultObject(_ result: Any) -> Self?
}
@@ -55,7 +55,7 @@ public protocol SelectValueResultType: SelectResultType {
*/
public protocol SelectAttributesResultType: SelectResultType {
static func fromResultObjects(_ result: [AnyObject]) -> [[NSString: AnyObject]]
static func fromResultObjects(_ result: [Any]) -> [[String: Any]]
}
@@ -103,7 +103,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
- 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 "average(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute
*/
public static func average(_ keyPath: KeyPath, As alias: KeyPath? = nil) -> SelectTerm {
public static func average(_ keyPath: KeyPath, as alias: KeyPath? = nil) -> SelectTerm {
return ._aggregate(
function: "average:",
@@ -125,7 +125,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
- 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
*/
public static func count(_ keyPath: KeyPath, As alias: KeyPath? = nil) -> SelectTerm {
public static func count(_ keyPath: KeyPath, as alias: KeyPath? = nil) -> SelectTerm {
return ._aggregate(
function: "count:",
@@ -147,7 +147,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
- 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 `SelectTerm` to a `Select` clause for querying the maximum value for an attribute
*/
public static func maximum(_ keyPath: KeyPath, As alias: KeyPath? = nil) -> SelectTerm {
public static func maximum(_ keyPath: KeyPath, as alias: KeyPath? = nil) -> SelectTerm {
return ._aggregate(
function: "max:",
@@ -169,7 +169,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
- 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 `SelectTerm` to a `Select` clause for querying the minimum value for an attribute
*/
public static func minimum(_ keyPath: KeyPath, As alias: KeyPath? = nil) -> SelectTerm {
public static func minimum(_ keyPath: KeyPath, as alias: KeyPath? = nil) -> SelectTerm {
return ._aggregate(
function: "min:",
@@ -191,7 +191,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
- 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 `SelectTerm` to a `Select` clause for querying the sum value for an attribute
*/
public static func sum(_ keyPath: KeyPath, As alias: KeyPath? = nil) -> SelectTerm {
public static func sum(_ keyPath: KeyPath, as alias: KeyPath? = nil) -> SelectTerm {
return ._aggregate(
function: "sum:",
@@ -214,7 +214,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
- 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
*/
public static func objectID(As alias: KeyPath? = nil) -> SelectTerm {
public static func objectID(as alias: KeyPath? = nil) -> SelectTerm {
return ._identity(
alias: alias ?? "objectID",
@@ -402,7 +402,7 @@ extension Bool: SelectValueResultType {
return .booleanAttributeType
}
public static func fromResultObject(_ result: AnyObject) -> Bool? {
public static func fromResultObject(_ result: Any) -> Bool? {
switch result {
case let decimal as NSDecimalNumber:
@@ -429,7 +429,7 @@ extension Int8: SelectValueResultType {
return .integer64AttributeType
}
public static func fromResultObject(_ result: AnyObject) -> Int8? {
public static func fromResultObject(_ result: Any) -> Int8? {
guard let value = (result as? NSNumber)?.int64Value else {
@@ -449,7 +449,7 @@ extension Int16: SelectValueResultType {
return .integer64AttributeType
}
public static func fromResultObject(_ result: AnyObject) -> Int16? {
public static func fromResultObject(_ result: Any) -> Int16? {
guard let value = (result as? NSNumber)?.int64Value else {
@@ -469,7 +469,7 @@ extension Int32: SelectValueResultType {
return .integer64AttributeType
}
public static func fromResultObject(_ result: AnyObject) -> Int32? {
public static func fromResultObject(_ result: Any) -> Int32? {
guard let value = (result as? NSNumber)?.int64Value else {
@@ -489,7 +489,7 @@ extension Int64: SelectValueResultType {
return .integer64AttributeType
}
public static func fromResultObject(_ result: AnyObject) -> Int64? {
public static func fromResultObject(_ result: Any) -> Int64? {
return (result as? NSNumber)?.int64Value
}
@@ -505,7 +505,7 @@ extension Int: SelectValueResultType {
return .integer64AttributeType
}
public static func fromResultObject(_ result: AnyObject) -> Int? {
public static func fromResultObject(_ result: Any) -> Int? {
guard let value = (result as? NSNumber)?.int64Value else {
@@ -525,7 +525,7 @@ extension Double: SelectValueResultType {
return .doubleAttributeType
}
public static func fromResultObject(_ result: AnyObject) -> Double? {
public static func fromResultObject(_ result: Any) -> Double? {
return (result as? NSNumber)?.doubleValue
}
@@ -541,7 +541,7 @@ extension Float: SelectValueResultType {
return .floatAttributeType
}
public static func fromResultObject(_ result: AnyObject) -> Float? {
public static func fromResultObject(_ result: Any) -> Float? {
return (result as? NSNumber)?.floatValue
}
@@ -557,7 +557,7 @@ extension String: SelectValueResultType {
return .stringAttributeType
}
public static func fromResultObject(_ result: AnyObject) -> String? {
public static func fromResultObject(_ result: Any) -> String? {
return result as? String
}
@@ -573,7 +573,7 @@ extension Date: SelectValueResultType {
return .dateAttributeType
}
public static func fromResultObject(_ result: AnyObject) -> Date? {
public static func fromResultObject(_ result: Any) -> Date? {
return result as? Date
}
@@ -589,7 +589,7 @@ extension Data: SelectValueResultType {
return .binaryDataAttributeType
}
public static func fromResultObject(_ result: AnyObject) -> Data? {
public static func fromResultObject(_ result: Any) -> Data? {
return result as? Data
}
@@ -605,9 +605,9 @@ extension NSNumber: SelectValueResultType {
return .integer64AttributeType
}
public class func fromResultObject(_ result: AnyObject) -> Self? {
public class func fromResultObject(_ result: Any) -> Self? {
func forceCast<T: NSNumber>(_ object: AnyObject) -> T? {
func forceCast<T: NSNumber>(_ object: Any) -> T? {
return (object as? T)
}
@@ -625,9 +625,9 @@ extension NSString: SelectValueResultType {
return .stringAttributeType
}
public class func fromResultObject(_ result: AnyObject) -> Self? {
public class func fromResultObject(_ result: Any) -> Self? {
func forceCast<T: NSString>(_ object: AnyObject) -> T? {
func forceCast<T: NSString>(_ object: Any) -> T? {
return (object as? T)
}
@@ -645,9 +645,9 @@ extension NSDecimalNumber {
return .decimalAttributeType
}
public override class func fromResultObject(_ result: AnyObject) -> Self? {
public override class func fromResultObject(_ result: Any) -> Self? {
func forceCast<T: NSDecimalNumber>(_ object: AnyObject) -> T? {
func forceCast<T: NSDecimalNumber>(_ object: Any) -> T? {
return (object as? T)
}
@@ -665,9 +665,9 @@ extension NSDate: SelectValueResultType {
return .dateAttributeType
}
public class func fromResultObject(_ result: AnyObject) -> Self? {
public class func fromResultObject(_ result: Any) -> Self? {
func forceCast<T: NSDate>(_ object: AnyObject) -> T? {
func forceCast<T: NSDate>(_ object: Any) -> T? {
return (object as? T)
}
@@ -685,9 +685,9 @@ extension NSData: SelectValueResultType {
return .binaryDataAttributeType
}
public class func fromResultObject(_ result: AnyObject) -> Self? {
public class func fromResultObject(_ result: Any) -> Self? {
func forceCast<T: NSData>(_ object: AnyObject) -> T? {
func forceCast<T: NSData>(_ object: Any) -> T? {
return (object as? T)
}
@@ -705,9 +705,9 @@ extension NSManagedObjectID: SelectValueResultType {
return .objectIDAttributeType
}
public class func fromResultObject(_ result: AnyObject) -> Self? {
public class func fromResultObject(_ result: Any) -> Self? {
func forceCast<T: NSManagedObjectID>(_ object: AnyObject) -> T? {
func forceCast<T: NSManagedObjectID>(_ object: Any) -> T? {
return (object as? T)
}
@@ -722,9 +722,9 @@ extension NSDictionary: SelectAttributesResultType {
// MARK: SelectAttributesResultType
public class func fromResultObjects(_ result: [AnyObject]) -> [[NSString: AnyObject]] {
public class func fromResultObjects(_ result: [Any]) -> [[String: Any]] {
return result as! [[NSString: AnyObject]]
return result as! [[String: Any]]
}
}
@@ -761,7 +761,7 @@ internal extension Collection where Iterator.Element == SelectTerm {
}
}
var propertiesToFetch = [AnyObject]()
var propertiesToFetch = [Any]()
for term in self {
switch term {

View File

@@ -79,7 +79,7 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
- parameter format: the format string for the predicate
- parameter args: the arguments for `format`
*/
public init(_ format: String, _ args: NSObject...) {
public init(_ format: String, _ args: Any...) {
self.init(NSPredicate(format: format, argumentArray: args))
}
@@ -90,7 +90,7 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
- parameter format: the format string for the predicate
- parameter argumentArray: the arguments for `format`
*/
public init(_ format: String, argumentArray: [NSObject]?) {
public init(_ format: String, argumentArray: [Any]?) {
self.init(NSPredicate(format: format, argumentArray: argumentArray))
}
@@ -101,7 +101,7 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
- parameter keyPath: the keyPath to compare with
- parameter value: the arguments for the `==` operator
*/
public init(_ keyPath: KeyPath, isEqualTo value: NSObject?) {
public init(_ keyPath: KeyPath, isEqualTo value: Any?) {
self.init(value == nil
? NSPredicate(format: "\(keyPath) == nil")
@@ -114,7 +114,7 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
- parameter keyPath: the keyPath to compare with
- parameter list: the array to check membership of
*/
public init(_ keyPath: KeyPath, isMemberOf list: [NSObject]) {
public init(_ keyPath: KeyPath, isMemberOf list: [Any]) {
self.init(NSPredicate(format: "\(keyPath) IN %@", list))
}
@@ -125,7 +125,7 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
- parameter keyPath: the keyPath to compare with
- parameter list: the sequence to check membership of
*/
public init<S: Sequence>(_ keyPath: KeyPath, isMemberOf list: S) where S.Iterator.Element: NSObject {
public init<S: Sequence>(_ keyPath: KeyPath, isMemberOf list: S) where S.Iterator.Element: Any {
self.init(NSPredicate(format: "\(keyPath) IN %@", Array(list) as NSArray))
}

View File

@@ -235,7 +235,7 @@ public extension CoreStore {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/
public static func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[NSString: AnyObject]]? {
public static func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
return self.defaultStack.queryAttributes(from, selectClause, queryClauses)
}
@@ -250,7 +250,7 @@ public extension CoreStore {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/
public static func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[NSString: AnyObject]]? {
public static func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
return self.defaultStack.queryAttributes(from, selectClause, queryClauses)
}

View File

@@ -297,7 +297,7 @@ public extension DataStack {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/
public func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[NSString: AnyObject]]? {
public func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
CoreStore.assert(
Thread.isMainThread,
@@ -316,7 +316,7 @@ public extension DataStack {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/
public func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[NSString: AnyObject]]? {
public func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
CoreStore.assert(
Thread.isMainThread,

View File

@@ -36,7 +36,7 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
// MARK: Internal
@nonobjc
internal convenience init<T: NSManagedObject>(dataStack: DataStack, fetchRequest: NSFetchRequest<NSManagedObject>, from: From<T>? = nil, sectionBy: SectionBy? = nil, applyFetchClauses: (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
internal convenience init<T: NSManagedObject>(dataStack: DataStack, fetchRequest: NSFetchRequest<NSManagedObject>, from: From<T>? = nil, sectionBy: SectionBy? = nil, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
self.init(
context: dataStack.mainContext,
@@ -48,7 +48,7 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
}
@nonobjc
internal init<T: NSManagedObject>(context: NSManagedObjectContext, fetchRequest: NSFetchRequest<NSManagedObject>, from: From<T>? = nil, sectionBy: SectionBy? = nil, applyFetchClauses: (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
internal init<T: NSManagedObject>(context: NSManagedObjectContext, fetchRequest: NSFetchRequest<NSManagedObject>, from: From<T>? = nil, sectionBy: SectionBy? = nil, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
_ = from?.applyToFetchRequest(
fetchRequest,

View File

@@ -30,22 +30,22 @@ import Foundation
internal extension DispatchQueue {
internal convenience init(serialWith label: String) {
internal convenience init(serialWith label: String, qos: DispatchQoS = .default) {
self.init(
label: label,
qos: .default,
attributes: .allZeros,
qos: qos,
attributes: [],
autoreleaseFrequency: .inherit,
target: nil
)
}
internal convenience init(concurrentWith label: String) {
internal convenience init(concurrentWith label: String, qos: DispatchQoS = .default) {
self.init(
label: label,
qos: .default,
qos: qos,
attributes: .concurrent,
autoreleaseFrequency: .inherit,
target: nil
@@ -62,20 +62,20 @@ internal extension DispatchQueue {
internal func cs_sync<T>(_ closure: () throws -> T) rethrows -> T {
return self.sync { autoreleasepool(invoking: closure) }
return try self.sync { try autoreleasepool(invoking: closure) }
}
internal func cs_async(_ closure: () -> Void) {
internal func cs_async(_ closure: @escaping () -> Void) {
self.async { autoreleasepool(invoking: closure) }
}
internal func cs_barrierSync<T>(_ closure: () throws -> T) rethrows -> T {
return self.sync(flags: .barrier) { autoreleasepool(invoking: closure) }
return try self.sync(flags: .barrier) { try autoreleasepool(invoking: closure) }
}
internal func cs_barrierAsync(_ closure: () -> Void) {
internal func cs_barrierAsync(_ closure: @escaping () -> Void) {
self.async(flags: .barrier) { autoreleasepool(invoking: closure) }
}

View File

@@ -33,7 +33,7 @@ import CoreData
internal protocol FetchedResultsControllerHandler: class {
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeObject anObject: AnyObject, atIndexPath indexPath: IndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: IndexPath?)
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeObject anObject: Any, atIndexPath indexPath: IndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: IndexPath?)
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType)
@@ -101,7 +101,7 @@ internal final class FetchedResultsControllerDelegate<EntityType: NSManagedObjec
}
@objc
dynamic func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: AnyObject, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
dynamic func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
guard self.enabled else {

View File

@@ -27,7 +27,7 @@ import Foundation
// MARK: Associated Objects
internal func cs_getAssociatedObjectForKey<T: AnyObject>(_ key: UnsafeRawPointer, inObject object: AnyObject) -> T? {
internal func cs_getAssociatedObjectForKey<T: AnyObject>(_ key: UnsafeRawPointer, inObject object: Any) -> T? {
switch objc_getAssociatedObject(object, key) {
@@ -42,17 +42,17 @@ internal func cs_getAssociatedObjectForKey<T: AnyObject>(_ key: UnsafeRawPointer
}
}
internal func cs_setAssociatedRetainedObject<T: AnyObject>(_ associatedObject: T?, forKey key: UnsafeRawPointer, inObject object: AnyObject) {
internal func cs_setAssociatedRetainedObject<T: AnyObject>(_ associatedObject: T?, forKey key: UnsafeRawPointer, inObject object: Any) {
objc_setAssociatedObject(object, key, associatedObject, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
internal func cs_setAssociatedCopiedObject<T: AnyObject>(_ associatedObject: T?, forKey key: UnsafeRawPointer, inObject object: AnyObject) {
internal func cs_setAssociatedCopiedObject<T: AnyObject>(_ associatedObject: T?, forKey key: UnsafeRawPointer, inObject object: Any) {
objc_setAssociatedObject(object, key, associatedObject, .OBJC_ASSOCIATION_COPY_NONATOMIC)
}
internal func cs_setAssociatedWeakObject<T: AnyObject>(_ associatedObject: T?, forKey key: UnsafeRawPointer, inObject object: AnyObject) {
internal func cs_setAssociatedWeakObject<T: AnyObject>(_ associatedObject: T?, forKey key: UnsafeRawPointer, inObject object: Any) {
if let associatedObject = associatedObject {

View File

@@ -425,7 +425,7 @@ internal extension NSManagedObjectContext {
@nonobjc
internal func queryValue<U: SelectValueResultType>(_ selectTerms: [SelectTerm], fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> U? {
var fetchResults: [AnyObject]?
var fetchResults: [Any]?
var fetchError: Error?
self.performAndWait {
@@ -441,7 +441,7 @@ internal extension NSManagedObjectContext {
if let fetchResults = fetchResults {
if let rawResult = fetchResults.first as? NSDictionary,
let rawObject: AnyObject = rawResult[selectTerms.keyPathForFirstSelectTerm()] {
let rawObject = rawResult[selectTerms.keyPathForFirstSelectTerm()] {
return Select<U>.ReturnType.fromResultObject(rawObject)
}
@@ -456,9 +456,9 @@ internal extension NSManagedObjectContext {
}
@nonobjc
internal func queryValue(_ selectTerms: [SelectTerm], fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> AnyObject? {
internal func queryValue(_ selectTerms: [SelectTerm], fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> Any? {
var fetchResults: [AnyObject]?
var fetchResults: [Any]?
var fetchError: Error?
self.performAndWait {
@@ -474,7 +474,7 @@ internal extension NSManagedObjectContext {
if let fetchResults = fetchResults {
if let rawResult = fetchResults.first as? NSDictionary,
let rawObject: AnyObject = rawResult[selectTerms.keyPathForFirstSelectTerm()] {
let rawObject = rawResult[selectTerms.keyPathForFirstSelectTerm()] {
return rawObject
}
@@ -492,13 +492,13 @@ internal extension NSManagedObjectContext {
// MARK: Internal: Attributes
@nonobjc
internal func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[NSString: AnyObject]]? {
internal func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
return self.queryAttributes(from, selectClause, queryClauses)
}
@nonobjc
internal func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[NSString: AnyObject]]? {
internal func queryAttributes<T: NSManagedObject>(_ from: From<T>, _ selectClause: Select<NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
let fetchRequest = CoreStoreFetchRequest<NSFetchRequestResult>()
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
@@ -516,9 +516,9 @@ internal extension NSManagedObjectContext {
}
@nonobjc
internal func queryAttributes(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> [[NSString: AnyObject]]? {
internal func queryAttributes(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> [[String: Any]]? {
var fetchResults: [AnyObject]?
var fetchResults: [Any]?
var fetchError: Error?
self.performAndWait {

View File

@@ -155,7 +155,7 @@ internal extension NSManagedObjectContext {
DispatchQueue.main.async {
completion(result: SaveResult(hasChanges: false))
completion(SaveResult(hasChanges: false))
}
return
}
@@ -175,7 +175,7 @@ internal extension NSManagedObjectContext {
)
DispatchQueue.main.async {
completion(result: SaveResult(saveError))
completion(SaveResult(saveError))
}
return
}
@@ -188,7 +188,7 @@ internal extension NSManagedObjectContext {
DispatchQueue.main.async {
completion(result: SaveResult(hasChanges: true))
completion(SaveResult(hasChanges: true))
}
}
}

View File

@@ -42,7 +42,7 @@ internal extension NSManagedObjectModel {
}
let modelFileURL = URL(fileURLWithPath: modelFilePath)
let versionInfoPlistURL = try! modelFileURL.appendingPathComponent("VersionInfo.plist", isDirectory: false)
let versionInfoPlistURL = modelFileURL.appendingPathComponent("VersionInfo.plist", isDirectory: false)
guard let versionInfo = NSDictionary(contentsOf: versionInfoPlistURL),
let versionHashes = versionInfo["NSManagedObjectModel_VersionHashes"] as? [String: AnyObject] else {
@@ -84,7 +84,7 @@ internal extension NSManagedObjectModel {
var modelVersionFileURL: URL?
for modelVersion in modelVersions {
let fileURL = try! modelFileURL.appendingPathComponent("\(modelVersion).mom", isDirectory: false)
let fileURL = modelFileURL.appendingPathComponent("\(modelVersion).mom", isDirectory: false)
if modelVersion == currentModelVersion {
@@ -190,7 +190,7 @@ internal extension NSManagedObjectModel {
return nil
}
let versionModelFileURL = try! modelFileURL.appendingPathComponent("\(modelVersion).mom", isDirectory: false)
let versionModelFileURL = modelFileURL.appendingPathComponent("\(modelVersion).mom", isDirectory: false)
guard let model = NSManagedObjectModel(contentsOf: versionModelFileURL) else {
return nil
@@ -203,7 +203,7 @@ internal extension NSManagedObjectModel {
}
@nonobjc
internal subscript(metadata: [String: AnyObject]) -> NSManagedObjectModel? {
internal subscript(metadata: [String: Any]) -> NSManagedObjectModel? {
guard let modelHashes = metadata[NSStoreModelVersionHashesKey] as? [String : Data] else {
@@ -227,7 +227,7 @@ internal extension NSManagedObjectModel {
get {
return try! self.modelVersionFileURL?.deletingLastPathComponent()
return self.modelVersionFileURL?.deletingLastPathComponent()
}
}

View File

@@ -66,15 +66,15 @@ internal extension NSPersistentStore {
// MARK: - StorageObject
private class StorageObject: NSObject {
fileprivate class StorageObject: NSObject {
// MARK: Private
@nonobjc
private let storageInterface: StorageInterface?
fileprivate let storageInterface: StorageInterface?
@nonobjc
private init(_ storage: StorageInterface?) {
fileprivate init(_ storage: StorageInterface?) {
self.storageInterface = storage
}

View File

@@ -934,14 +934,14 @@ private func createFormattedString(_ firstLine: String, _ lastLine: String, _ in
return string
}
private extension String {
fileprivate extension String {
private static func indention(_ level: Int = 1) -> String {
fileprivate static func indention(_ level: Int = 1) -> String {
return String(repeating: Character(" "), count: level * 4)
return String(repeating: " ", count: level * 4)
}
private func trimSwiftModuleName() -> String {
fileprivate func trimSwiftModuleName() -> String {
if self.hasPrefix("Swift.") {
@@ -950,12 +950,12 @@ private extension String {
return self
}
private mutating func indent(_ level: Int) {
fileprivate mutating func indent(_ level: Int) {
self = self.replacingOccurrences(of: "\n", with: "\n\(String.indention(level))")
}
private mutating func appendDumpInfo(_ key: String, _ value: Any) {
fileprivate mutating func appendDumpInfo(_ key: String, _ value: Any) {
self.append("\n.\(key) = \(formattedValue(value));")
}
@@ -1071,7 +1071,7 @@ extension Bundle: CoreStoreDebugStringConvertible {
public var coreStoreDumpString: String {
return "\(self.bundleIdentifier.flatMap({ "\"\($0)\"" }) ?? "<unknown bundle identifier>") (\(self.bundleURL.lastPathComponent ?? "<unknown bundle URL>"))"
return "\(self.bundleIdentifier.flatMap({ "\"\($0)\"" }) ?? "<unknown bundle identifier>") (\(self.bundleURL.lastPathComponent))"
}
}

View File

@@ -70,7 +70,7 @@ public final class DefaultLogger: CoreStoreLogger {
icon = ""
levelString = "Fatal"
}
Swift.print("\(icon) [CoreStore: \(levelString)] \((String(fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n")
Swift.print("\(icon) [CoreStore: \(levelString)] \((String(describing: fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n")
#endif
}
@@ -86,7 +86,7 @@ public final class DefaultLogger: CoreStoreLogger {
public func log(error: CoreStoreError, message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString) {
#if DEBUG
Swift.print("⚠️ [CoreStore: Error] \((String(fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n \(error)\n")
Swift.print("⚠️ [CoreStore: Error] \((String(describing: fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n \(error)\n")
#endif
}
@@ -106,7 +106,7 @@ public final class DefaultLogger: CoreStoreLogger {
return
}
Swift.print("❗ [CoreStore: Assertion Failure] \((String(fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message())\n")
Swift.print("❗ [CoreStore: Assertion Failure] \((String(describing: fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message())\n")
Swift.fatalError(file: fileName, line: UInt(lineNumber))
#endif
}
@@ -122,7 +122,7 @@ public final class DefaultLogger: CoreStoreLogger {
*/
public func abort(_ message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString) {
Swift.print("❗ [CoreStore: Fatal Error] \((String(fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n")
Swift.print("❗ [CoreStore: Fatal Error] \((String(describing: fileName) as NSString).lastPathComponent):\(lineNumber) \(functionName)\n ↪︎ \(message)\n")
Swift.fatalError(file: fileName, line: UInt(lineNumber))
}
}

View File

@@ -47,7 +47,7 @@ public extension CoreStore {
- parameter storeType: the storage type
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `StorageInterface` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `StorageInterface` was already added at the same URL and with the same configuration.
*/
public static func addStorage<T: StorageInterface>(_ storeType: T.Type, completion: (SetupResult<T>) -> Void) where T: DefaultInitializableStore {
public static func addStorage<T: StorageInterface>(_ storeType: T.Type, completion: @escaping (SetupResult<T>) -> Void) where T: DefaultInitializableStore {
self.defaultStack.addStorage(storeType.init(), completion: completion)
}
@@ -68,7 +68,7 @@ public extension CoreStore {
- parameter storage: the storage
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `StorageInterface` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `StorageInterface` was already added at the same URL and with the same configuration.
*/
public static func addStorage<T: StorageInterface>(_ storage: T, completion: (SetupResult<T>) -> Void) {
public static func addStorage<T: StorageInterface>(_ storage: T, completion: @escaping (SetupResult<T>) -> Void) {
self.defaultStack.addStorage(storage, completion: completion)
}
@@ -90,7 +90,7 @@ public extension CoreStore {
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `LocalStorage` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `LocalStorage` was already added at the same URL and with the same configuration.
- returns: an `NSProgress` instance if a migration has started, or `nil` if either no migrations are required or if a failure occured.
*/
public static func addStorage<T: LocalStorage>(_ storeType: T.Type, completion: (SetupResult<T>) -> Void) -> Progress? where T: DefaultInitializableStore {
public static func addStorage<T: LocalStorage>(_ storeType: T.Type, completion: @escaping (SetupResult<T>) -> Void) -> Progress? where T: DefaultInitializableStore {
return self.defaultStack.addStorage(storeType.init(), completion: completion)
}
@@ -112,7 +112,7 @@ public extension CoreStore {
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `LocalStorage` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `LocalStorage` was already added at the same URL and with the same configuration.
- returns: an `NSProgress` instance if a migration has started, or `nil` if either no migrations are required or if a failure occured.
*/
public static func addStorage<T: LocalStorage>(_ storage: T, completion: (SetupResult<T>) -> Void) -> Progress? {
public static func addStorage<T: LocalStorage>(_ storage: T, completion: @escaping (SetupResult<T>) -> Void) -> Progress? {
return self.defaultStack.addStorage(storage, completion: completion)
}
@@ -144,7 +144,7 @@ public extension CoreStore {
- parameter storage: the cloud storage
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `CloudStorage` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `CloudStorage` was already added at the same URL and with the same configuration.
*/
public static func addStorage<T: CloudStorage>(_ storage: T, completion: (SetupResult<T>) -> Void) {
public static func addStorage<T: CloudStorage>(_ storage: T, completion: @escaping (SetupResult<T>) -> Void) {
self.defaultStack.addStorage(storage, completion: completion)
}
@@ -157,7 +157,7 @@ public extension CoreStore {
- throws: a `CoreStoreError` value indicating the failure
- returns: an `NSProgress` instance if a migration has started, or `nil` is no migrations are required
*/
public static func upgradeStorageIfNeeded<T: LocalStorage>(_ storage: T, completion: (MigrationResult) -> Void) throws -> Progress? {
public static func upgradeStorageIfNeeded<T: LocalStorage>(_ storage: T, completion: @escaping (MigrationResult) -> Void) throws -> Progress? {
return try self.defaultStack.upgradeStorageIfNeeded(storage, completion: completion)
}

View File

@@ -47,7 +47,7 @@ public extension DataStack {
- parameter storeType: the storage type
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `StorageInterface` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `StorageInterface` was already added at the same URL and with the same configuration.
*/
public func addStorage<T: StorageInterface>(_ storeType: T.Type, completion: (SetupResult<T>) -> Void) where T: DefaultInitializableStore {
public func addStorage<T: StorageInterface>(_ storeType: T.Type, completion: @escaping (SetupResult<T>) -> Void) where T: DefaultInitializableStore {
self.addStorage(storeType.init(), completion: completion)
}
@@ -126,7 +126,7 @@ public extension DataStack {
- parameter completion: the closure to be executed on the main queue when the process completes, either due to success or failure. The closure's `SetupResult` argument indicates the result. Note that the `LocalStorage` associated to the `SetupResult.success` may not always be the same instance as the parameter argument if a previous `LocalStorage` was already added at the same URL and with the same configuration.
- returns: an `NSProgress` instance if a migration has started, or `nil` if either no migrations are required or if a failure occured.
*/
public func addStorage<T: LocalStorage>(_ storeType: T.Type, completion: (SetupResult<T>) -> Void) -> Progress? where T: DefaultInitializableStore {
public func addStorage<T: LocalStorage>(_ storeType: T.Type, completion: @escaping (SetupResult<T>) -> Void) -> Progress? where T: DefaultInitializableStore {
return self.addStorage(storeType.init() as! T.Type, completion: completion)
}
@@ -194,7 +194,7 @@ public extension DataStack {
do {
try FileManager.default.createDirectory(
at: try fileURL.deletingLastPathComponent(),
at: fileURL.deletingLastPathComponent(),
withIntermediateDirectories: true,
attributes: nil
)
@@ -207,7 +207,7 @@ public extension DataStack {
return self.upgradeStorageIfNeeded(
storage,
metadata: metadata as [String : AnyObject],
metadata: metadata,
completion: { (result) -> Void in
if case .failure(.internalError(let error)) = result {
@@ -359,7 +359,7 @@ public extension DataStack {
do {
try FileManager.default.createDirectory(
at: try cacheFileURL.deletingLastPathComponent(),
at: cacheFileURL.deletingLastPathComponent(),
withIntermediateDirectories: true,
attributes: nil
)
@@ -431,7 +431,7 @@ public extension DataStack {
- throws: a `CoreStoreError` value indicating the failure
- returns: an `NSProgress` instance if a migration has started, or `nil` is no migrations are required
*/
public func upgradeStorageIfNeeded<T: LocalStorage>(_ storage: T, completion: (MigrationResult) -> Void) throws -> Progress? {
public func upgradeStorageIfNeeded<T: LocalStorage>(_ storage: T, completion: @escaping (MigrationResult) -> Void) throws -> Progress? {
return try self.coordinator.performSynchronously {
@@ -450,7 +450,7 @@ public extension DataStack {
)
return self.upgradeStorageIfNeeded(
storage,
metadata: metadata as [String : AnyObject],
metadata: metadata,
completion: completion
)
}
@@ -491,7 +491,7 @@ public extension DataStack {
options: storage.storeOptions
)
guard let migrationSteps = self.computeMigrationFromStorage(storage, metadata: metadata as [String : AnyObject]) else {
guard let migrationSteps = self.computeMigrationFromStorage(storage, metadata: metadata) else {
let error = CoreStoreError.mappingModelNotFound(
localStoreURL: fileURL,
@@ -537,7 +537,7 @@ public extension DataStack {
// MARK: Private
private func upgradeStorageIfNeeded<T: LocalStorage>(_ storage: T, metadata: [String: AnyObject], completion: @escaping (MigrationResult) -> Void) -> Progress? {
private func upgradeStorageIfNeeded<T: LocalStorage>(_ storage: T, metadata: [String: Any], completion: @escaping (MigrationResult) -> Void) -> Progress? {
guard let migrationSteps = self.computeMigrationFromStorage(storage, metadata: metadata) else {
@@ -654,7 +654,7 @@ public extension DataStack {
return progress
}
private func computeMigrationFromStorage<T: LocalStorage>(_ storage: T, metadata: [String: AnyObject]) -> [(sourceModel: NSManagedObjectModel, destinationModel: NSManagedObjectModel, mappingModel: NSMappingModel, migrationType: MigrationType)]? {
private func computeMigrationFromStorage<T: LocalStorage>(_ storage: T, metadata: [String: Any]) -> [(sourceModel: NSManagedObjectModel, destinationModel: NSManagedObjectModel, mappingModel: NSMappingModel, migrationType: MigrationType)]? {
let model = self.model
if model.isConfiguration(withName: storage.configuration, compatibleWithStoreMetadata: metadata) {
@@ -737,7 +737,7 @@ public extension DataStack {
let fileURL = storage.fileURL
let temporaryDirectoryURL = try! URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
let temporaryDirectoryURL = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
.appendingPathComponent(Bundle.main.bundleIdentifier ?? "com.CoreStore.DataStack")
.appendingPathComponent(ProcessInfo().globallyUniqueString)
@@ -748,7 +748,7 @@ public extension DataStack {
attributes: nil
)
let temporaryFileURL = try! temporaryDirectoryURL.appendingPathComponent(
let temporaryFileURL = temporaryDirectoryURL.appendingPathComponent(
fileURL.lastPathComponent,
isDirectory: false
)

View File

@@ -246,7 +246,7 @@ public struct MigrationChain: ExpressibleByNilLiteral, ExpressibleByStringLitera
// MARK: Private
private let versionTree: [String: String]
fileprivate let versionTree: [String: String]
}

View File

@@ -90,11 +90,11 @@ public enum MigrationResult: Hashable {
switch self {
case .success(let migrationTypes):
return self.boolValue.hashValue
return true.hashValue
^ migrationTypes.map { $0.hashValue }.reduce(0, ^).hashValue
case .failure(let error):
return self.boolValue.hashValue ^ error.hashValue
return false.hashValue ^ error.hashValue
}
}

View File

@@ -126,7 +126,7 @@ public enum MigrationType: Hashable {
public var hashValue: Int {
let preHash = self.boolValue.hashValue ^ self.isHeavyweightMigration.hashValue
let preHash = self.hasMigration.hashValue ^ self.isHeavyweightMigration.hashValue
switch self {
case .none(let version):

View File

@@ -93,10 +93,10 @@ public enum SetupResult<T: StorageInterface>: Hashable {
switch self {
case .success(let storage):
return self.boolValue.hashValue ^ ObjectIdentifier(storage).hashValue
return true.hashValue ^ ObjectIdentifier(storage).hashValue
case .failure(let error):
return self.boolValue.hashValue ^ error.hashValue
return false.hashValue ^ error.hashValue
}
}

View File

@@ -65,7 +65,7 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
self.bridgeToSwift.beginSynchronous { (transaction) in
closure(transaction: transaction.bridgeToObjectiveC)
closure(transaction.bridgeToObjectiveC)
}
}
}
@@ -88,7 +88,7 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
- returns: a new `NSManagedObject` instance of the specified entity type.
*/
@objc
public override func createInto(_ into: CSInto) -> AnyObject {
public override func createInto(_ into: CSInto) -> Any {
return self.bridgeToSwift.create(into.bridgeToSwift)
}
@@ -100,7 +100,7 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
- returns: an editable proxy for the specified `NSManagedObject`.
*/
@objc
public override func editObject(_ object: NSManagedObject?) -> AnyObject? {
public override func editObject(_ object: NSManagedObject?) -> Any? {
return self.bridgeToSwift.edit(object)
}
@@ -113,7 +113,7 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
- returns: an editable proxy for the specified `NSManagedObject`.
*/
@objc
public override func editInto(_ into: CSInto, objectID: NSManagedObjectID) -> AnyObject? {
public override func editInto(_ into: CSInto, objectID: NSManagedObjectID) -> Any? {
return self.bridgeToSwift.edit(into.bridgeToSwift, objectID)
}

View File

@@ -38,7 +38,7 @@ public extension CSBaseDataTransaction {
- returns: the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found.
*/
@objc
public func fetchExistingObject(_ object: NSManagedObject) -> AnyObject? {
public func fetchExistingObject(_ object: NSManagedObject) -> Any? {
do {
@@ -57,7 +57,7 @@ public extension CSBaseDataTransaction {
- returns: the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found.
*/
@objc
public func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> AnyObject? {
public func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> Any? {
do {
@@ -76,7 +76,7 @@ public extension CSBaseDataTransaction {
- returns: the `NSManagedObject` array for objects that exists in the transaction
*/
@objc
public func fetchExistingObjects(_ objects: [NSManagedObject]) -> [AnyObject] {
public func fetchExistingObjects(_ objects: [NSManagedObject]) -> [Any] {
return objects.flatMap { try? self.bridgeToSwift.context.existingObject(with: $0.objectID) }
}
@@ -88,7 +88,7 @@ public extension CSBaseDataTransaction {
- returns: the `NSManagedObject` array for objects that exists in the transaction
*/
@objc
public func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [AnyObject] {
public func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [Any] {
return objectIDs.flatMap { try? self.bridgeToSwift.context.existingObject(with: $0) }
}
@@ -101,7 +101,7 @@ public extension CSBaseDataTransaction {
- returns: the first `NSManagedObject` instance that satisfies the specified `CSFetchClause`s
*/
@objc
public func fetchOneFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> AnyObject? {
public func fetchOneFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> Any? {
CoreStore.assert(
self.bridgeToSwift.isRunningInAllowedQueue(),
@@ -118,7 +118,7 @@ public extension CSBaseDataTransaction {
- returns: all `NSManagedObject` instances that satisfy the specified `CSFetchClause`s
*/
@objc
public func fetchAllFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> [AnyObject]? {
public func fetchAllFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> [Any]? {
CoreStore.assert(
self.bridgeToSwift.isRunningInAllowedQueue(),
@@ -141,7 +141,9 @@ public extension CSBaseDataTransaction {
self.bridgeToSwift.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.bridgeToSwift.context.fetchCount(from, fetchClauses)
return self.bridgeToSwift.context
.fetchCount(from, fetchClauses)
.flatMap { NSNumber(value: $0) }
}
/**
@@ -172,7 +174,7 @@ public extension CSBaseDataTransaction {
- returns: the result of the the query. The type of the return value is specified by the generic type of the `CSSelect` parameter.
*/
@objc
public func queryValueFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> AnyObject? {
public func queryValueFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> Any? {
CoreStore.assert(
self.bridgeToSwift.isRunningInAllowedQueue(),
@@ -192,7 +194,7 @@ public extension CSBaseDataTransaction {
- returns: the result of the the query. The type of the return value is specified by the generic type of the `CSSelect` parameter.
*/
@objc
public func queryAttributesFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> [[NSString: AnyObject]]? {
public func queryAttributesFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> [[String: Any]]? {
CoreStore.assert(
self.bridgeToSwift.isRunningInAllowedQueue(),

View File

@@ -55,7 +55,7 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
- returns: a new `NSManagedObject` instance of the specified entity type.
*/
@objc
public func createInto(_ into: CSInto) -> AnyObject {
public func createInto(_ into: CSInto) -> Any {
return self.bridgeToSwift.create(into.bridgeToSwift)
}
@@ -67,7 +67,7 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
- returns: an editable proxy for the specified `NSManagedObject`.
*/
@objc
public func editObject(_ object: NSManagedObject?) -> AnyObject? {
public func editObject(_ object: NSManagedObject?) -> Any? {
return self.bridgeToSwift.edit(object)
}
@@ -80,7 +80,7 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
- returns: an editable proxy for the specified `NSManagedObject`.
*/
@objc
public func editInto(_ into: CSInto, objectID: NSManagedObjectID) -> AnyObject? {
public func editInto(_ into: CSInto, objectID: NSManagedObjectID) -> Any? {
return self.bridgeToSwift.edit(into.bridgeToSwift, objectID)
}

View File

@@ -47,7 +47,7 @@ public extension CSCoreStore {
- 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.
*/
public static func addInMemoryStorage(_ storage: CSInMemoryStore, completion: (CSSetupResult) -> Void) {
public static func addInMemoryStorage(_ storage: CSInMemoryStore, completion: @escaping (CSSetupResult) -> Void) {
self.defaultStack.addInMemoryStorage(storage, completion: completion)
}
@@ -72,7 +72,7 @@ public extension CSCoreStore {
- 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) -> Progress? {
public static func addSQLiteStorage(_ storage: CSSQLiteStore, completion: @escaping (CSSetupResult) -> Void, error: NSErrorPointer) -> Progress? {
return self.defaultStack.addSQLiteStorage(storage, completion: completion, error: error)
}
@@ -86,7 +86,7 @@ public extension CSCoreStore {
- returns: an `NSProgress` instance if a migration has started. `nil` if no migrations are required or if `error` was set.
*/
@objc
public static func upgradeStorageIfNeeded(_ storage: CSSQLiteStore, completion: (CSMigrationResult) -> Void, error: NSErrorPointer) -> Progress? {
public static func upgradeStorageIfNeeded(_ storage: CSSQLiteStore, completion: @escaping (CSMigrationResult) -> Void, error: NSErrorPointer) -> Progress? {
return self.defaultStack.upgradeStorageIfNeeded(storage, completion: completion, error: error)
}

View File

@@ -66,7 +66,7 @@ public extension CSCoreStore {
- parameter fetchClauses: a series of `CSFetchClause` instances for fetching the object list. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.
*/
@objc
public static func monitorListByCreatingAsynchronously(_ createAsynchronously: (CSListMonitor) -> Void, from: CSFrom, fetchClauses: [CSFetchClause]) {
public static func monitorListByCreatingAsynchronously(_ createAsynchronously: @escaping (CSListMonitor) -> Void, from: CSFrom, fetchClauses: [CSFetchClause]) {
return self.defaultStack.monitorListByCreatingAsynchronously(
createAsynchronously,
@@ -102,7 +102,7 @@ public extension CSCoreStore {
- parameter fetchClauses: a series of `CSFetchClause` instances for fetching the object list. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.
*/
@objc
public static func monitorSectionedListByCreatingAsynchronously(_ createAsynchronously: (CSListMonitor) -> Void, from: CSFrom, sectionBy: CSSectionBy, fetchClauses: [CSFetchClause]) {
public static func monitorSectionedListByCreatingAsynchronously(_ createAsynchronously: @escaping (CSListMonitor) -> Void, from: CSFrom, sectionBy: CSSectionBy, fetchClauses: [CSFetchClause]) {
self.defaultStack.monitorSectionedListByCreatingAsynchronously(
createAsynchronously,

View File

@@ -38,7 +38,7 @@ public extension CSCoreStore {
- returns: the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found.
*/
@objc
public static func fetchExistingObject(_ object: NSManagedObject) -> AnyObject? {
public static func fetchExistingObject(_ object: NSManagedObject) -> Any? {
return self.defaultStack.fetchExistingObject(object)
}
@@ -50,7 +50,7 @@ public extension CSCoreStore {
- returns: the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found.
*/
@objc
public static func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> AnyObject? {
public static func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> Any? {
return self.defaultStack.fetchExistingObjectWithID(objectID)
}
@@ -62,7 +62,7 @@ public extension CSCoreStore {
- returns: the `NSManagedObject` array for objects that exists in the transaction
*/
@objc
public static func fetchExistingObjects(_ objects: [NSManagedObject]) -> [AnyObject] {
public static func fetchExistingObjects(_ objects: [NSManagedObject]) -> [Any] {
return self.defaultStack.fetchExistingObjects(objects)
}
@@ -74,7 +74,7 @@ public extension CSCoreStore {
- returns: the `NSManagedObject` array for objects that exists in the transaction
*/
@objc
public static func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [AnyObject] {
public static func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [Any] {
return self.defaultStack.fetchExistingObjectsWithIDs(objectIDs)
}
@@ -87,7 +87,7 @@ public extension CSCoreStore {
- returns: the first `NSManagedObject` instance that satisfies the specified `CSFetchClause`s
*/
@objc
public static func fetchOneFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> AnyObject? {
public static func fetchOneFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> Any? {
return self.defaultStack.fetchOneFrom(from, fetchClauses: fetchClauses)
}
@@ -100,7 +100,7 @@ public extension CSCoreStore {
- returns: all `NSManagedObject` instances that satisfy the specified `CSFetchClause`s
*/
@objc
public static func fetchAllFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> [AnyObject]? {
public static func fetchAllFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> [Any]? {
return self.defaultStack.fetchAllFrom(from, fetchClauses: fetchClauses)
}
@@ -155,7 +155,7 @@ public extension CSCoreStore {
- returns: the result of the the query. The type of the return value is specified by the generic type of the `CSSelect` parameter.
*/
@objc
public static func queryValueFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> AnyObject? {
public static func queryValueFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> Any? {
return self.defaultStack.queryValueFrom(from, selectClause: selectClause, queryClauses: queryClauses)
}
@@ -171,7 +171,7 @@ public extension CSCoreStore {
- returns: the result of the the query. The type of the return value is specified by the generic type of the `CSSelect` parameter.
*/
@objc
public static func queryAttributesFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> [[NSString: AnyObject]]? {
public static func queryAttributesFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> [[String: Any]]? {
return self.defaultStack.queryAttributesFrom(from, selectClause: selectClause, queryClauses: queryClauses)
}

View File

@@ -58,7 +58,7 @@ public extension CSCoreStore {
CoreStore.beginSynchronous { (transaction) in
closure(transaction: transaction.bridgeToObjectiveC)
closure(transaction.bridgeToObjectiveC)
}
}
}

View File

@@ -48,7 +48,7 @@ public extension CSDataStack {
- 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.
*/
@objc
public func addInMemoryStorage(_ storage: CSInMemoryStore, completion: (CSSetupResult) -> Void) {
public func addInMemoryStorage(_ storage: CSInMemoryStore, completion: @escaping (CSSetupResult) -> Void) {
self.bridgeToSwift.addStorage(
storage.bridgeToSwift,
@@ -77,7 +77,7 @@ public extension CSDataStack {
- returns: an `NSProgress` instance if a migration has started. `nil` if no migrations are required or if `error` was set.
*/
@objc
public func addSQLiteStorage(_ storage: CSSQLiteStore, completion: (CSSetupResult) -> Void, error: NSErrorPointer) -> Progress? {
public func addSQLiteStorage(_ storage: CSSQLiteStore, completion: @escaping (CSSetupResult) -> Void, error: NSErrorPointer) -> Progress? {
return bridge(error) {
@@ -97,7 +97,7 @@ public extension CSDataStack {
- returns: an `NSProgress` instance if a migration has started. `nil` if no migrations are required or if `error` was set.
*/
@objc
public func upgradeStorageIfNeeded(_ storage: CSSQLiteStore, completion: (CSMigrationResult) -> Void, error: NSErrorPointer) -> Progress? {
public func upgradeStorageIfNeeded(_ storage: CSSQLiteStore, completion: @escaping (CSMigrationResult) -> Void, error: NSErrorPointer) -> Progress? {
return bridge(error) {

View File

@@ -88,7 +88,7 @@ public extension CSDataStack {
- parameter fetchClauses: a series of `CSFetchClause` instances for fetching the object list. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.
*/
@objc
public func monitorListByCreatingAsynchronously(_ createAsynchronously: (CSListMonitor) -> Void, from: CSFrom, fetchClauses: [CSFetchClause]) {
public func monitorListByCreatingAsynchronously(_ createAsynchronously: @escaping (CSListMonitor) -> Void, from: CSFrom, fetchClauses: [CSFetchClause]) {
CoreStore.assert(
Thread.isMainThread,
@@ -154,7 +154,7 @@ public extension CSDataStack {
- parameter sectionBy: a `CSSectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections.
- parameter fetchClauses: a series of `CSFetchClause` instances for fetching the object list. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.
*/
public func monitorSectionedListByCreatingAsynchronously(_ createAsynchronously: (CSListMonitor) -> Void, from: CSFrom, sectionBy: CSSectionBy, fetchClauses: [CSFetchClause]) {
public func monitorSectionedListByCreatingAsynchronously(_ createAsynchronously: @escaping (CSListMonitor) -> Void, from: CSFrom, sectionBy: CSSectionBy, fetchClauses: [CSFetchClause]) {
CoreStore.assert(
Thread.isMainThread,

View File

@@ -38,7 +38,7 @@ public extension CSDataStack {
- returns: the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found.
*/
@objc
public func fetchExistingObject(_ object: NSManagedObject) -> AnyObject? {
public func fetchExistingObject(_ object: NSManagedObject) -> Any? {
do {
@@ -57,7 +57,7 @@ public extension CSDataStack {
- returns: the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found.
*/
@objc
public func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> AnyObject? {
public func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> Any? {
do {
@@ -76,7 +76,7 @@ public extension CSDataStack {
- returns: the `NSManagedObject` array for objects that exists in the transaction
*/
@objc
public func fetchExistingObjects(_ objects: [NSManagedObject]) -> [AnyObject] {
public func fetchExistingObjects(_ objects: [NSManagedObject]) -> [Any] {
return objects.flatMap { try? self.bridgeToSwift.mainContext.existingObject(with: $0.objectID) }
}
@@ -88,7 +88,7 @@ public extension CSDataStack {
- returns: the `NSManagedObject` array for objects that exists in the transaction
*/
@objc
public func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [AnyObject] {
public func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [Any] {
return objectIDs.flatMap { try? self.bridgeToSwift.mainContext.existingObject(with: $0) }
}
@@ -101,7 +101,7 @@ public extension CSDataStack {
- returns: the first `NSManagedObject` instance that satisfies the specified `CSFetchClause`s
*/
@objc
public func fetchOneFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> AnyObject? {
public func fetchOneFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> Any? {
CoreStore.assert(
Thread.isMainThread,
@@ -118,7 +118,7 @@ public extension CSDataStack {
- returns: all `NSManagedObject` instances that satisfy the specified `CSFetchClause`s
*/
@objc
public func fetchAllFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> [AnyObject]? {
public func fetchAllFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> [Any]? {
CoreStore.assert(
Thread.isMainThread,
@@ -141,7 +141,9 @@ public extension CSDataStack {
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.bridgeToSwift.mainContext.fetchCount(from, fetchClauses)
return self.bridgeToSwift.mainContext
.fetchCount(from, fetchClauses)
.flatMap { NSNumber(value: $0) }
}
/**
@@ -189,7 +191,7 @@ public extension CSDataStack {
- returns: the result of the the query. The type of the return value is specified by the generic type of the `CSSelect` parameter.
*/
@objc
public func queryValueFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> AnyObject? {
public func queryValueFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> Any? {
CoreStore.assert(
Thread.isMainThread,
@@ -209,7 +211,7 @@ public extension CSDataStack {
- returns: the result of the the query. The type of the return value is specified by the generic type of the `CSSelect` parameter.
*/
@objc
public func queryAttributesFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> [[NSString: AnyObject]]? {
public func queryAttributesFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> [[String: Any]]? {
CoreStore.assert(
Thread.isMainThread,

View File

@@ -58,7 +58,7 @@ public extension CSDataStack {
self.bridgeToSwift.beginSynchronous { (transaction) in
closure(transaction: transaction.bridgeToObjectiveC)
closure(transaction.bridgeToObjectiveC)
}
}
}

View File

@@ -140,7 +140,7 @@ public final class CSError: NSError, CoreStoreObjectiveCType {
self.swiftError = swiftValue
let code: CoreStoreErrorCode
let info: [NSObject: AnyObject]
let info: [AnyHashable: Any]
switch swiftValue {
case .unknown:
@@ -150,27 +150,27 @@ public final class CSError: NSError, CoreStoreObjectiveCType {
case .differentStorageExistsAtURL(let existingPersistentStoreURL):
code = .differentStorageExistsAtURL
info = [
"existingPersistentStoreURL" as NSObject: existingPersistentStoreURL as AnyObject
"existingPersistentStoreURL": existingPersistentStoreURL
]
case .mappingModelNotFound(let localStoreURL, let targetModel, let targetModelVersion):
code = .mappingModelNotFound
info = [
"localStoreURL" as NSObject: localStoreURL as AnyObject,
"targetModel" as NSObject: targetModel,
"targetModelVersion" as NSObject: targetModelVersion as AnyObject
"localStoreURL": localStoreURL,
"targetModel": targetModel,
"targetModelVersion": targetModelVersion
]
case .progressiveMigrationRequired(let localStoreURL):
code = .progressiveMigrationRequired
info = [
"localStoreURL" as NSObject: localStoreURL as AnyObject
"localStoreURL": localStoreURL
]
case .internalError(let NSError):
code = .internalError
info = [
"NSError" as NSObject: NSError
"NSError": NSError
]
}

View File

@@ -51,7 +51,7 @@ public final class CSFrom: NSObject, CoreStoreObjectiveCType {
May contain `NSString` instances to pertain to named configurations, or `NSNull` to pertain to the default configuration
*/
@objc
public var configurations: [AnyObject]? {
public var configurations: [Any]? {
return self.bridgeToSwift.configurations?.map {
@@ -85,7 +85,7 @@ public final class CSFrom: NSObject, CoreStoreObjectiveCType {
- 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 `[NSNull null]` to use the default configuration.
*/
@objc
public convenience init(entityClass: AnyClass, configuration: AnyObject) {
public convenience init(entityClass: AnyClass, configuration: Any) {
switch configuration {
@@ -111,7 +111,7 @@ public final class CSFrom: NSObject, CoreStoreObjectiveCType {
- parameter configurations: an array of the `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.
*/
@objc
public convenience init(entityClass: AnyClass, configurations: [AnyObject]) {
public convenience init(entityClass: AnyClass, configurations: [Any]) {
var arguments = [String?]()
for configuration in configurations {

View File

@@ -79,7 +79,7 @@ public final class CSInMemoryStore: NSObject, CSStorageInterface, CoreStoreObjec
The options dictionary for the `NSPersistentStore`. For `CSInMemoryStore`s, this is always set to `nil`.
*/
@objc
public var storeOptions: [String: AnyObject]? {
public var storeOptions: [AnyHashable: Any]? {
return self.bridgeToSwift.storeOptions
}

View File

@@ -48,7 +48,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
- returns: the `NSManagedObject` at the specified index
*/
@objc
public subscript(index: Int) -> AnyObject {
public subscript(index: Int) -> Any {
return self.bridgeToSwift[index]
}
@@ -60,7 +60,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
- returns: the `NSManagedObject` at the specified index, or `nil` if out of bounds
*/
@objc
public func objectAtSafeIndex(_ index: Int) -> AnyObject? {
public func objectAtSafeIndex(_ index: Int) -> Any? {
return self.bridgeToSwift[safeIndex: index]
}
@@ -73,12 +73,10 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
- returns: the `NSManagedObject` at the specified section and item index
*/
@objc
public func objectAtSectionIndex(_ sectionIndex: Int, itemIndex: Int) -> AnyObject {
public func objectAtSectionIndex(_ sectionIndex: Int, itemIndex: Int) -> Any {
return self.bridgeToSwift[sectionIndex, itemIndex]
}
/**
} /**
Returns the object at the given section and item index, or `nil` if out of bounds. This indexer is typically used for `CSListMonitor`s created as sectioned lists.
- parameter sectionIndex: the section index for the object. Using a `sectionIndex` with an invalid range will return `nil`.
@@ -86,7 +84,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
- returns: the `NSManagedObject` at the specified section and item index, or `nil` if out of bounds
*/
@objc
public func objectAtSafeSectionIndex(_ sectionIndex: Int, safeItemIndex itemIndex: Int) -> AnyObject? {
public func objectAtSafeSectionIndex(_ sectionIndex: Int, safeItemIndex itemIndex: Int) -> Any? {
return self.bridgeToSwift[safeSectionIndex: sectionIndex, safeItemIndex: itemIndex]
}
@@ -98,7 +96,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
- returns: the `NSManagedObject` at the specified index path
*/
@objc
public func objectAtIndexPath(_ indexPath: IndexPath) -> AnyObject {
public func objectAtIndexPath(_ indexPath: IndexPath) -> Any {
return self.bridgeToSwift[indexPath]
}
@@ -110,7 +108,7 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
- returns: the `NSManagedObject` at the specified index path, or `nil` if out of bounds
*/
@objc
public func objectAtSafeIndexPath(_ indexPath: IndexPath) -> AnyObject? {
public func objectAtSafeIndexPath(_ indexPath: IndexPath) -> Any? {
return self.bridgeToSwift[safeIndexPath: indexPath]
}
@@ -216,7 +214,9 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
@objc
public func numberOfObjectsInSafeSection(safeSectionIndex section: Int) -> NSNumber? {
return self.bridgeToSwift.numberOfObjectsInSection(safeSectionIndex: section)
return self.bridgeToSwift
.numberOfObjectsInSection(safeSectionIndex: section)
.flatMap { NSNumber(value: $0) }
}
/**
@@ -287,7 +287,9 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
@objc
public func indexOf(_ object: NSManagedObject) -> NSNumber? {
return self.bridgeToSwift.indexOf(object)
return self.bridgeToSwift
.indexOf(object)
.flatMap { NSNumber(value: $0) }
}
/**

View File

@@ -103,7 +103,7 @@ public protocol CSListObjectObserver: CSListObserver {
- parameter indexPath: the new `NSIndexPath` for the inserted object
*/
@objc
optional func listMonitor(_ monitor: CSListMonitor, didInsertObject object: AnyObject, toIndexPath indexPath: IndexPath)
optional func listMonitor(_ monitor: CSListMonitor, didInsertObject object: Any, toIndexPath indexPath: IndexPath)
/**
Notifies that an object was deleted from the specified `NSIndexPath` in the list
@@ -113,7 +113,7 @@ public protocol CSListObjectObserver: CSListObserver {
- parameter indexPath: the `NSIndexPath` for the deleted object
*/
@objc
optional func listMonitor(_ monitor: CSListMonitor, didDeleteObject object: AnyObject, fromIndexPath indexPath: IndexPath)
optional func listMonitor(_ monitor: CSListMonitor, didDeleteObject object: Any, fromIndexPath indexPath: IndexPath)
/**
Notifies that an object at the specified `NSIndexPath` was updated
@@ -123,7 +123,7 @@ public protocol CSListObjectObserver: CSListObserver {
- parameter indexPath: the `NSIndexPath` for the updated object
*/
@objc
optional func listMonitor(_ monitor: CSListMonitor, didUpdateObject object: AnyObject, atIndexPath indexPath: IndexPath)
optional func listMonitor(_ monitor: CSListMonitor, didUpdateObject object: Any, atIndexPath indexPath: IndexPath)
/**
Notifies that an object's index changed
@@ -134,7 +134,7 @@ public protocol CSListObjectObserver: CSListObserver {
- parameter toIndexPath: the new `NSIndexPath` for the moved object
*/
@objc
optional func listMonitor(_ monitor: CSListMonitor, didMoveObject object: AnyObject, fromIndexPath: IndexPath, toIndexPath: IndexPath)
optional func listMonitor(_ monitor: CSListMonitor, didMoveObject object: Any, fromIndexPath: IndexPath, toIndexPath: IndexPath)
}

View File

@@ -43,7 +43,7 @@ public final class CSMigrationResult: NSObject, CoreStoreObjectiveCType {
@objc
public var isSuccess: Bool {
return self.bridgeToSwift.boolValue
return self.bridgeToSwift.isSuccess
}
/**
@@ -52,7 +52,7 @@ public final class CSMigrationResult: NSObject, CoreStoreObjectiveCType {
@objc
public var isFailure: Bool {
return !self.bridgeToSwift.boolValue
return !self.bridgeToSwift.isSuccess
}
/**

View File

@@ -43,7 +43,7 @@ public final class CSMigrationType: NSObject, CoreStoreObjectiveCType {
@objc
public var needsMigration: Bool {
return self.bridgeToSwift.boolValue
return self.bridgeToSwift.hasMigration
}
/**

View File

@@ -42,7 +42,7 @@ public final class CSObjectMonitor: NSObject, CoreStoreObjectiveCType {
/**
Returns the `NSManagedObject` instance being observed, or `nil` if the object was already deleted.
*/
public var object: AnyObject? {
public var object: Any? {
return self.bridgeToSwift.object
}

View File

@@ -50,7 +50,7 @@ public protocol CSObjectObserver: class, AnyObject {
- parameter object: the `NSManagedObject` instance being observed
*/
@objc
optional func objectMonitor(_ monitor: CSObjectMonitor, willUpdateObject object: AnyObject)
optional func objectMonitor(_ monitor: CSObjectMonitor, willUpdateObject object: Any)
/**
Handles processing right after a change to the observed `object` occurs
@@ -60,7 +60,7 @@ public protocol CSObjectObserver: class, AnyObject {
- parameter changedPersistentKeys: an `NSSet` of key paths for the attributes that were changed. Note that `changedPersistentKeys` only contains keys for attributes/relationships present in the persistent store, thus transient properties will not be reported.
*/
@objc
optional func objectMonitor(_ monitor: CSObjectMonitor, didUpdateObject object: AnyObject, changedPersistentKeys: Set<String>)
optional func objectMonitor(_ monitor: CSObjectMonitor, didUpdateObject object: Any, changedPersistentKeys: Set<String>)
/**
Handles processing right after `object` is deleted
@@ -69,7 +69,7 @@ public protocol CSObjectObserver: class, AnyObject {
- parameter object: the `NSManagedObject` instance being observed
*/
@objc
optional func objectMonitor(_ monitor: CSObjectMonitor, didDeleteObject object: AnyObject)
optional func objectMonitor(_ monitor: CSObjectMonitor, didDeleteObject object: Any)
}
#endif

View File

@@ -41,7 +41,7 @@ public final class CSOrderBy: NSObject, CSFetchClause, CSQueryClause, CSDeleteCl
The list of sort descriptors
*/
@objc
public var sortDescriptors: [SortDescriptor] {
public var sortDescriptors: [NSSortDescriptor] {
return self.bridgeToSwift.sortDescriptors
}
@@ -56,7 +56,7 @@ public final class CSOrderBy: NSObject, CSFetchClause, CSQueryClause, CSDeleteCl
- parameter sortDescriptor: a `NSSortDescriptor`
*/
@objc
public convenience init(sortDescriptor: SortDescriptor) {
public convenience init(sortDescriptor: NSSortDescriptor) {
self.init(OrderBy(sortDescriptor))
}
@@ -71,7 +71,7 @@ public final class CSOrderBy: NSObject, CSFetchClause, CSQueryClause, CSDeleteCl
- parameter sortDescriptors: an array of `NSSortDescriptor`s
*/
@objc
public convenience init(sortDescriptors: [SortDescriptor]) {
public convenience init(sortDescriptors: [NSSortDescriptor]) {
self.init(OrderBy(sortDescriptors))
}

View File

@@ -145,7 +145,7 @@ public final class CSSQLiteStore: NSObject, CSLocalStorage, CoreStoreObjectiveCT
```
*/
@objc
public var storeOptions: [String: AnyObject]? {
public var storeOptions: [AnyHashable: Any]? {
return self.bridgeToSwift.storeOptions
}

View File

@@ -59,7 +59,7 @@ public final class CSSectionBy: NSObject, CoreStoreObjectiveCType {
- returns: a `CSSectionBy` clause with the key path to use to group `CSListMonitor` objects into sections
*/
@objc
public static func keyPath(_ sectionKeyPath: KeyPath, sectionIndexTransformer: (_ sectionName: String?) -> String?) -> CSSectionBy {
public static func keyPath(_ sectionKeyPath: KeyPath, sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> CSSectionBy {
return self.init(SectionBy(sectionKeyPath, sectionIndexTransformer))
}

View File

@@ -67,7 +67,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
@objc
public static func average(_ keyPath: KeyPath, as alias: KeyPath?) -> CSSelectTerm {
return self.init(.average(keyPath, As: alias))
return self.init(.average(keyPath, as: alias))
}
/**
@@ -84,7 +84,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
@objc
public static func count(_ keyPath: KeyPath, as alias: KeyPath?) -> CSSelectTerm {
return self.init(.count(keyPath, As: alias))
return self.init(.count(keyPath, as: alias))
}
/**
@@ -101,7 +101,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
@objc
public static func maximum(_ keyPath: KeyPath, as alias: KeyPath?) -> CSSelectTerm {
return self.init(.maximum(keyPath, As: alias))
return self.init(.maximum(keyPath, as: alias))
}
/**
@@ -118,7 +118,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
@objc
public static func minimum(_ keyPath: KeyPath, as alias: KeyPath?) -> CSSelectTerm {
return self.init(.minimum(keyPath, As: alias))
return self.init(.minimum(keyPath, as: alias))
}
/**
@@ -135,7 +135,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
@objc
public static func sum(_ keyPath: KeyPath, as alias: KeyPath?) -> CSSelectTerm {
return self.init(.sum(keyPath, As: alias))
return self.init(.sum(keyPath, as: alias))
}
/**
@@ -153,7 +153,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
@objc
public static func objectIDAs(_ alias: KeyPath? = nil) -> CSSelectTerm {
return self.init(.objectID(As: alias))
return self.init(.objectID(as: alias))
}

View File

@@ -53,7 +53,7 @@ public protocol CSStorageInterface {
The options dictionary for the `NSPersistentStore`
*/
@objc
var storeOptions: [String: AnyObject]? { get }
var storeOptions: [AnyHashable: Any]? { get }
}

View File

@@ -65,7 +65,7 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
self.bridgeToSwift.beginSynchronous { (transaction) in
closure(transaction: transaction.bridgeToObjectiveC)
closure(transaction.bridgeToObjectiveC)
}
}
}
@@ -88,7 +88,7 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
- returns: a new `NSManagedObject` instance of the specified entity type.
*/
@objc
public override func createInto(_ into: CSInto) -> AnyObject {
public override func createInto(_ into: CSInto) -> Any {
return self.bridgeToSwift.create(into.bridgeToSwift)
}
@@ -100,7 +100,7 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
- returns: an editable proxy for the specified `NSManagedObject`.
*/
@objc
public override func editObject(_ object: NSManagedObject?) -> AnyObject? {
public override func editObject(_ object: NSManagedObject?) -> Any? {
return self.bridgeToSwift.edit(object)
}
@@ -113,7 +113,7 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
- returns: an editable proxy for the specified `NSManagedObject`.
*/
@objc
public override func editInto(_ into: CSInto, objectID: NSManagedObjectID) -> AnyObject? {
public override func editInto(_ into: CSInto, objectID: NSManagedObjectID) -> Any? {
return self.bridgeToSwift.edit(into.bridgeToSwift, objectID)
}

View File

@@ -53,7 +53,7 @@ public final class CSTweak: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
- parameter block: the block to customize the `NSFetchRequest`
*/
@objc
public convenience init(block: (_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> Void) {
public convenience init(block: @escaping (_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> Void) {
self.init(Tweak(block))
}

View File

@@ -41,7 +41,7 @@ public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
The internal `NSPredicate` instance for the `Where` clause
*/
@objc
public var predicate: Predicate {
public var predicate: NSPredicate {
return self.bridgeToSwift.predicate
}
@@ -108,7 +108,7 @@ public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
- parameter predicate: the `NSPredicate` for the fetch or query
*/
@objc
public convenience init(predicate: Predicate) {
public convenience init(predicate: NSPredicate) {
self.init(Where(predicate))
}

View File

@@ -38,7 +38,7 @@ public extension NSManagedObject {
- returns: the primitive value for the KVC key
*/
@objc
public func cs_accessValueForKVCKey(_ KVCKey: KeyPath) -> AnyObject? {
public func cs_accessValueForKVCKey(_ KVCKey: KeyPath) -> Any? {
return self.accessValueForKVCKey(KVCKey)
}
@@ -50,7 +50,7 @@ public extension NSManagedObject {
- parameter KVCKey: the KVC key
*/
@objc
public func cs_setValue(_ value: AnyObject?, forKVCKey KVCKey: KeyPath) {
public func cs_setValue(_ value: Any?, forKVCKey KVCKey: KeyPath) {
self.setValue(value, forKVCKey: KVCKey)
}

View File

@@ -135,7 +135,7 @@ internal extension NSManagedObjectContext {
}
@nonobjc
internal func queryValue(_ from: CSFrom, _ selectClause: CSSelect, _ queryClauses: [CSQueryClause]) -> AnyObject? {
internal func queryValue(_ from: CSFrom, _ selectClause: CSSelect, _ queryClauses: [CSQueryClause]) -> Any? {
let fetchRequest = CoreStoreFetchRequest<NSFetchRequestResult>()
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
@@ -154,7 +154,7 @@ internal extension NSManagedObjectContext {
}
@nonobjc
internal func queryAttributes(_ from: CSFrom, _ selectClause: CSSelect, _ queryClauses: [CSQueryClause]) -> [[NSString: AnyObject]]? {
internal func queryAttributes(_ from: CSFrom, _ selectClause: CSSelect, _ queryClauses: [CSQueryClause]) -> [[String: Any]]? {
let fetchRequest = CoreStoreFetchRequest<NSFetchRequestResult>()
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)

View File

@@ -75,7 +75,7 @@ public extension CoreStore {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
*/
public static func monitorList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: FetchClause...) {
public static func monitorList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: FetchClause...) {
self.defaultStack.monitorList(createAsynchronously: createAsynchronously, from, fetchClauses)
}
@@ -87,7 +87,7 @@ public extension CoreStore {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
*/
public static func monitorList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: [FetchClause]) {
public static func monitorList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: [FetchClause]) {
self.defaultStack.monitorList(createAsynchronously: createAsynchronously, from, fetchClauses)
}
@@ -126,7 +126,7 @@ public extension CoreStore {
- parameter sectionBy: a `SectionBy` 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 `Where`, `OrderBy`, and `Tweak` clauses.
*/
public static func monitorSectionedList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) {
public static func monitorSectionedList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) {
self.defaultStack.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
}
@@ -139,7 +139,7 @@ public extension CoreStore {
- parameter sectionBy: a `SectionBy` 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 `Where`, `OrderBy`, and `Tweak` clauses.
*/
public static func monitorSectionedList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) {
public static func monitorSectionedList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) {
self.defaultStack.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
}

View File

@@ -96,7 +96,7 @@ public extension DataStack {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
*/
public func monitorList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: FetchClause...) {
public func monitorList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: FetchClause...) {
self.monitorList(createAsynchronously: createAsynchronously, from, fetchClauses)
}
@@ -108,7 +108,7 @@ public extension DataStack {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
*/
public func monitorList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: [FetchClause]) {
public func monitorList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: [FetchClause]) {
CoreStore.assert(
Thread.isMainThread,
@@ -183,7 +183,7 @@ public extension DataStack {
- parameter sectionBy: a `SectionBy` 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 `Where`, `OrderBy`, and `Tweak` clauses.
*/
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) {
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) {
self.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
}
@@ -196,7 +196,7 @@ public extension DataStack {
- parameter sectionBy: a `SectionBy` 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 `Where`, `OrderBy`, and `Tweak` clauses.
*/
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) {
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) {
CoreStore.assert(
Thread.isMainThread,

View File

@@ -604,7 +604,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
// MARK: Internal
internal convenience init(dataStack: DataStack, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
internal convenience init(dataStack: DataStack, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
self.init(
context: dataStack.mainContext,
@@ -616,7 +616,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
)
}
internal convenience init(dataStack: DataStack, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void, createAsynchronously: (ListMonitor<T>) -> Void) {
internal convenience init(dataStack: DataStack, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void, createAsynchronously: @escaping (ListMonitor<T>) -> Void) {
self.init(
context: dataStack.mainContext,
@@ -628,7 +628,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
)
}
internal convenience init(unsafeTransaction: UnsafeDataTransaction, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
internal convenience init(unsafeTransaction: UnsafeDataTransaction, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
self.init(
context: unsafeTransaction.context,
@@ -640,7 +640,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
)
}
internal convenience init(unsafeTransaction: UnsafeDataTransaction, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void, createAsynchronously: (ListMonitor<T>) -> Void) {
internal convenience init(unsafeTransaction: UnsafeDataTransaction, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void, createAsynchronously: @escaping (ListMonitor<T>) -> Void) {
self.init(
context: unsafeTransaction.context,
@@ -687,15 +687,15 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
guard let `self` = self,
let userInfo = note.userInfo,
let object = userInfo[String(NSManagedObject.self)] as? T else {
let object = userInfo[String(describing: NSManagedObject.self)] as? T else {
return
}
callback(
self,
object,
userInfo[String(IndexPath.self)] as? IndexPath,
userInfo["\(String(IndexPath.self)).New"] as? IndexPath
userInfo[String(describing: IndexPath.self)] as? IndexPath,
userInfo["\(String(describing: IndexPath.self)).New"] as? IndexPath
)
}
),
@@ -714,8 +714,8 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
guard let `self` = self,
let userInfo = note.userInfo,
let sectionInfo = userInfo[String(NSFetchedResultsSectionInfo.self)] as? NSFetchedResultsSectionInfo,
let sectionIndex = (userInfo[String(NSNumber.self)] as? NSNumber)?.intValue else {
let sectionInfo = userInfo[String(describing: NSFetchedResultsSectionInfo.self)] as? NSFetchedResultsSectionInfo,
let sectionIndex = (userInfo[String(describing: NSNumber.self)] as? NSNumber)?.intValue else {
return
}
@@ -743,7 +743,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
return
}
willChange(observer: observer, monitor: monitor)
willChange(observer, monitor)
}
)
self.registerChangeNotification(
@@ -756,7 +756,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
return
}
didChange(observer: observer, monitor: monitor)
didChange(observer, monitor)
}
)
self.registerChangeNotification(
@@ -769,7 +769,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
return
}
willRefetch(observer: observer, monitor: monitor)
willRefetch(observer, monitor)
}
)
self.registerChangeNotification(
@@ -782,7 +782,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
return
}
didRefetch(observer: observer, monitor: monitor)
didRefetch(observer, monitor)
}
)
}
@@ -804,12 +804,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
return
}
didInsertObject(
observer: observer,
monitor: monitor,
object: object,
toIndexPath: newIndexPath!
)
didInsertObject(observer, monitor, object, newIndexPath!)
}
)
self.registerObjectNotification(
@@ -822,12 +817,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
return
}
didDeleteObject(
observer: observer,
monitor: monitor,
object: object,
fromIndexPath: indexPath!
)
didDeleteObject(observer, monitor, object, indexPath!)
}
)
self.registerObjectNotification(
@@ -840,12 +830,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
return
}
didUpdateObject(
observer: observer,
monitor: monitor,
object: object,
atIndexPath: indexPath!
)
didUpdateObject(observer, monitor, object, indexPath!)
}
)
self.registerObjectNotification(
@@ -858,13 +843,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
return
}
didMoveObject(
observer: observer,
monitor: monitor,
object: object,
fromIndexPath: indexPath!,
toIndexPath: newIndexPath!
)
didMoveObject(observer, monitor, object, indexPath!, newIndexPath!)
}
)
}
@@ -886,12 +865,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
return
}
didInsertSection(
observer: observer,
monitor: monitor,
sectionInfo: sectionInfo,
toIndex: sectionIndex
)
didInsertSection(observer, monitor, sectionInfo, sectionIndex)
}
)
self.registerSectionNotification(
@@ -904,12 +878,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
return
}
didDeleteSection(
observer: observer,
monitor: monitor,
sectionInfo: sectionInfo,
fromIndex: sectionIndex
)
didDeleteSection(observer, monitor, sectionInfo, sectionIndex)
}
)
}
@@ -953,7 +922,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
}
self.applyFetchClauses = applyFetchClauses
self.taskGroup.notify(.main) { [weak self] () -> Void in
self.taskGroup.notify(queue: .main) { [weak self] () -> Void in
guard let `self` = self else {
@@ -961,7 +930,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
}
self.fetchedResultsControllerDelegate.enabled = false
self.applyFetchClauses(fetchRequest: self.fetchedResultsController.fetchRequest)
self.applyFetchClauses(self.fetchedResultsController.fetchRequest)
self.transactionQueue.async { [weak self] in
@@ -1000,6 +969,10 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
// MARK: Private
fileprivate let fetchedResultsController: CoreStoreFetchedResultsController
fileprivate let taskGroup = DispatchGroup()
fileprivate let sectionIndexTransformer: (_ sectionName: KeyPath?) -> String?
private var willChangeListKey: Void?
private var didChangeListKey: Void?
private var willRefetchListKey: Void?
@@ -1013,12 +986,9 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
private var didInsertSectionKey: Void?
private var didDeleteSectionKey: Void?
private let fetchedResultsController: CoreStoreFetchedResultsController
private let fetchedResultsControllerDelegate: FetchedResultsControllerDelegate<T>
private let sectionIndexTransformer: (_ sectionName: KeyPath?) -> String?
private var observerForWillChangePersistentStore: NotificationObserver!
private var observerForDidChangePersistentStore: NotificationObserver!
private let taskGroup = DispatchGroup()
private let transactionQueue: DispatchQueue
private var applyFetchClauses: (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void
@@ -1043,7 +1013,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
}
}
private init(context: NSManagedObjectContext, transactionQueue: DispatchQueue, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void, createAsynchronously: ((ListMonitor<T>) -> Void)?) {
private init(context: NSManagedObjectContext, transactionQueue: DispatchQueue, from: From<T>, sectionBy: SectionBy?, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void, createAsynchronously: ((ListMonitor<T>) -> Void)?) {
let fetchRequest = CoreStoreFetchRequest<T>()
fetchRequest.fetchLimit = 0
@@ -1139,7 +1109,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
transactionQueue.async {
try! fetchedResultsController.performFetchFromSpecifiedStores()
self.taskGroup.notify(.main) {
self.taskGroup.notify(queue: .main) {
createAsynchronously(self)
}
@@ -1184,7 +1154,7 @@ extension ListMonitor: FetchedResultsControllerHandler {
// MARK: FetchedResultsControllerHandler
internal func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeObject anObject: AnyObject, atIndexPath indexPath: IndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
internal func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeObject anObject: Any, atIndexPath indexPath: IndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
switch type {
@@ -1193,8 +1163,8 @@ extension ListMonitor: FetchedResultsControllerHandler {
name: Notification.Name.listMonitorDidInsertObject,
object: self,
userInfo: [
String(NSManagedObject.self): anObject,
"\(String(IndexPath.self)).New": newIndexPath!
String(describing: NSManagedObject.self): anObject,
"\(String(describing: IndexPath.self)).New": newIndexPath!
]
)
@@ -1203,8 +1173,8 @@ extension ListMonitor: FetchedResultsControllerHandler {
name: Notification.Name.listMonitorDidDeleteObject,
object: self,
userInfo: [
String(NSManagedObject.self): anObject,
String(IndexPath.self): indexPath!
String(describing: NSManagedObject.self): anObject,
String(describing: IndexPath.self): indexPath!
]
)
@@ -1213,8 +1183,8 @@ extension ListMonitor: FetchedResultsControllerHandler {
name: Notification.Name.listMonitorDidUpdateObject,
object: self,
userInfo: [
String(NSManagedObject.self): anObject,
String(IndexPath.self): indexPath!
String(describing: NSManagedObject.self): anObject,
String(describing: IndexPath.self): indexPath!
]
)
@@ -1223,9 +1193,9 @@ extension ListMonitor: FetchedResultsControllerHandler {
name: Notification.Name.listMonitorDidMoveObject,
object: self,
userInfo: [
String(NSManagedObject.self): anObject,
String(IndexPath.self): indexPath!,
"\(String(IndexPath.self)).New": newIndexPath!
String(describing: NSManagedObject.self): anObject,
String(describing: IndexPath.self): indexPath!,
"\(String(describing: IndexPath.self)).New": newIndexPath!
]
)
}
@@ -1240,8 +1210,8 @@ extension ListMonitor: FetchedResultsControllerHandler {
name: Notification.Name.listMonitorDidInsertSection,
object: self,
userInfo: [
String(NSFetchedResultsSectionInfo.self): sectionInfo,
String(NSNumber.self): NSNumber(value: sectionIndex)
String(describing: NSFetchedResultsSectionInfo.self): sectionInfo,
String(describing: NSNumber.self): NSNumber(value: sectionIndex)
]
)
@@ -1250,8 +1220,8 @@ extension ListMonitor: FetchedResultsControllerHandler {
name: Notification.Name.listMonitorDidDeleteSection,
object: self,
userInfo: [
String(NSFetchedResultsSectionInfo.self): sectionInfo,
String(NSNumber.self): NSNumber(value: sectionIndex)
String(describing: NSFetchedResultsSectionInfo.self): sectionInfo,
String(describing: NSNumber.self): NSNumber(value: sectionIndex)
]
)
@@ -1280,25 +1250,25 @@ extension ListMonitor: FetchedResultsControllerHandler {
internal func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, sectionIndexTitleForSectionName sectionName: String?) -> String? {
return self.sectionIndexTransformer(sectionName: sectionName)
return self.sectionIndexTransformer(sectionName)
}
}
// MARK: - Notification Keys
private extension Notification.Name {
fileprivate extension Notification.Name {
private static let listMonitorWillChangeList = Notification.Name(rawValue: "listMonitorWillChangeList")
private static let listMonitorDidChangeList = Notification.Name(rawValue: "listMonitorDidChangeList")
private static let listMonitorWillRefetchList = Notification.Name(rawValue: "listMonitorWillRefetchList")
private static let listMonitorDidRefetchList = Notification.Name(rawValue: "listMonitorDidRefetchList")
private static let listMonitorDidInsertObject = Notification.Name(rawValue: "listMonitorDidInsertObject")
private static let listMonitorDidDeleteObject = Notification.Name(rawValue: "listMonitorDidDeleteObject")
private static let listMonitorDidUpdateObject = Notification.Name(rawValue: "listMonitorDidUpdateObject")
private static let listMonitorDidMoveObject = Notification.Name(rawValue: "listMonitorDidMoveObject")
private static let listMonitorDidInsertSection = Notification.Name(rawValue: "listMonitorDidInsertSection")
private static let listMonitorDidDeleteSection = Notification.Name(rawValue: "listMonitorDidDeleteSection")
fileprivate static let listMonitorWillChangeList = Notification.Name(rawValue: "listMonitorWillChangeList")
fileprivate static let listMonitorDidChangeList = Notification.Name(rawValue: "listMonitorDidChangeList")
fileprivate static let listMonitorWillRefetchList = Notification.Name(rawValue: "listMonitorWillRefetchList")
fileprivate static let listMonitorDidRefetchList = Notification.Name(rawValue: "listMonitorDidRefetchList")
fileprivate static let listMonitorDidInsertObject = Notification.Name(rawValue: "listMonitorDidInsertObject")
fileprivate static let listMonitorDidDeleteObject = Notification.Name(rawValue: "listMonitorDidDeleteObject")
fileprivate static let listMonitorDidUpdateObject = Notification.Name(rawValue: "listMonitorDidUpdateObject")
fileprivate static let listMonitorDidMoveObject = Notification.Name(rawValue: "listMonitorDidMoveObject")
fileprivate static let listMonitorDidInsertSection = Notification.Name(rawValue: "listMonitorDidInsertSection")
fileprivate static let listMonitorDidDeleteSection = Notification.Name(rawValue: "listMonitorDidDeleteSection")
}
#endif

View File

@@ -322,7 +322,7 @@ extension ObjectMonitor: FetchedResultsControllerHandler {
internal func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) { }
internal func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeObject anObject: AnyObject, atIndexPath indexPath: IndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
internal func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeObject anObject: Any, atIndexPath indexPath: IndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
switch type {

View File

@@ -91,7 +91,7 @@ public extension UnsafeDataTransaction {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
*/
public func monitorList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: FetchClause...) {
public func monitorList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: FetchClause...) {
self.monitorList(createAsynchronously: createAsynchronously, from, fetchClauses)
}
@@ -103,7 +103,7 @@ public extension UnsafeDataTransaction {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
*/
public func monitorList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: [FetchClause]) {
public func monitorList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ fetchClauses: [FetchClause]) {
CoreStore.assert(
fetchClauses.filter { $0 is OrderBy }.count > 0,
@@ -169,7 +169,7 @@ public extension UnsafeDataTransaction {
- parameter sectionBy: a `SectionBy` 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 `Where`, `OrderBy`, and `Tweak` clauses.
*/
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) {
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) {
self.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
}
@@ -182,7 +182,7 @@ public extension UnsafeDataTransaction {
- parameter sectionBy: a `SectionBy` 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 `Where`, `OrderBy`, and `Tweak` clauses.
*/
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) {
public func monitorSectionedList<T: NSManagedObject>(createAsynchronously: @escaping (ListMonitor<T>) -> Void, _ from: From<T>, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) {
CoreStore.assert(
fetchClauses.filter { $0 is OrderBy }.count > 0,

View File

@@ -241,7 +241,7 @@ public final class DataStack {
do {
try FileManager.default.createDirectory(
at: try fileURL.deletingLastPathComponent(),
at: fileURL.deletingLastPathComponent(),
withIntermediateDirectories: true,
attributes: nil
)
@@ -336,7 +336,7 @@ public final class DataStack {
do {
try FileManager.default.createDirectory(
at: try cacheFileURL.deletingLastPathComponent(),
at: cacheFileURL.deletingLastPathComponent(),
withIntermediateDirectories: true,
attributes: nil
)
@@ -394,11 +394,8 @@ public final class DataStack {
migrationQueue.name = "com.coreStore.migrationOperationQueue"
migrationQueue.qualityOfService = .utility
migrationQueue.underlyingQueue = DispatchQueue(
label: "com.coreStore.migrationQueue",
qos: .userInitiated,
attributes: .allZeros,
autoreleaseFrequency: .workItem,
target: nil
serialWith: "com.coreStore.migrationQueue",
qos: .userInitiated
)
return migrationQueue
}()
@@ -462,7 +459,7 @@ public final class DataStack {
return returnValue
}
internal func createPersistentStoreFromStorage(_ storage: StorageInterface, finalURL: URL?, finalStoreOptions: [String: AnyObject]?) throws -> NSPersistentStore {
internal func createPersistentStoreFromStorage(_ storage: StorageInterface, finalURL: URL?, finalStoreOptions: [AnyHashable: Any]?) throws -> NSPersistentStore {
let persistentStore = try self.coordinator.addPersistentStore(
ofType: type(of: storage).storeType,

View File

@@ -85,12 +85,12 @@ public class ICloudStore: CloudStorage {
)
let fileManager = FileManager.default
guard let cacheFileURL = fileManager.urlForUbiquityContainerIdentifier(ubiquitousContainerID) else {
guard let cacheFileURL = fileManager.url(forUbiquityContainerIdentifier: ubiquitousContainerID) else {
return nil
}
var storeOptions: [String: AnyObject] = [
var storeOptions: [String: Any] = [
NSSQLitePragmasOption: ["journal_mode": "WAL"],
NSPersistentStoreUbiquitousContentNameKey: ubiquitousContentName
]
@@ -265,7 +265,7 @@ public class ICloudStore: CloudStorage {
[NSSQLitePragmasOption: ["journal_mode": "WAL"]]
```
*/
public let storeOptions: [String: AnyObject]?
public let storeOptions: [AnyHashable: Any]?
/**
Do not call directly. Used by the `DataStack` internally.
@@ -312,7 +312,7 @@ public class ICloudStore: CloudStorage {
NotificationCenter.default.post(
name: notification,
object: self,
userInfo: [String(DataStack.self): dataStack]
userInfo: [String(describing: DataStack.self): dataStack]
)
}
),
@@ -354,7 +354,7 @@ public class ICloudStore: CloudStorage {
NotificationCenter.default.post(
name: notification,
object: self,
userInfo: [String(DataStack.self): dataStack]
userInfo: [String(describing: DataStack.self): dataStack]
)
}
),
@@ -400,7 +400,7 @@ public class ICloudStore: CloudStorage {
/**
The options dictionary for the specified `CloudStorageOptions`
*/
public func storeOptionsForOptions(_ options: CloudStorageOptions) -> [String: AnyObject]? {
public func storeOptionsForOptions(_ options: CloudStorageOptions) -> [AnyHashable: Any]? {
if options == .none {
@@ -453,10 +453,10 @@ public class ICloudStore: CloudStorage {
// MARK: Private
private struct Static {
fileprivate struct Static {
private static var persistentStoreCoordinatorWillChangeStores: Void?
private static var persistentStoreCoordinatorDidChangeStores: Void?
fileprivate static var persistentStoreCoordinatorWillChangeStores: Void?
fileprivate static var persistentStoreCoordinatorDidChangeStores: Void?
}
private var willFinishInitialImportKey: Void?
@@ -480,7 +480,7 @@ public class ICloudStore: CloudStorage {
guard let `self` = self,
let observer = observer,
let dataStack = note.userInfo?[String(DataStack.self)] as? DataStack,
let dataStack = note.userInfo?[String(describing: DataStack.self)] as? DataStack,
self.dataStack === dataStack else {
return
@@ -497,16 +497,16 @@ public class ICloudStore: CloudStorage {
// MARK: - Notification Keys
private extension Notification.Name {
fileprivate extension Notification.Name {
private static let iCloudUbiquitousStoreWillFinishInitialImport = Notification.Name(rawValue: "iCloudUbiquitousStoreWillFinishInitialImport")
private static let iCloudUbiquitousStoreDidFinishInitialImport = Notification.Name(rawValue: "iCloudUbiquitousStoreDidFinishInitialImport")
private static let iCloudUbiquitousStoreWillAddAccount = Notification.Name(rawValue: "iCloudUbiquitousStoreWillAddAccount")
private static let iCloudUbiquitousStoreDidAddAccount = Notification.Name(rawValue: "iCloudUbiquitousStoreDidAddAccount")
private static let iCloudUbiquitousStoreWillRemoveAccount = Notification.Name(rawValue: "iCloudUbiquitousStoreWillRemoveAccount")
private static let iCloudUbiquitousStoreDidRemoveAccount = Notification.Name(rawValue: "iCloudUbiquitousStoreDidRemoveAccount")
private static let iCloudUbiquitousStoreWillRemoveContent = Notification.Name(rawValue: "iCloudUbiquitousStoreWillRemoveContent")
private static let iCloudUbiquitousStoreDidRemoveContent = Notification.Name(rawValue: "iCloudUbiquitousStoreDidRemoveContent")
fileprivate static let iCloudUbiquitousStoreWillFinishInitialImport = Notification.Name(rawValue: "iCloudUbiquitousStoreWillFinishInitialImport")
fileprivate static let iCloudUbiquitousStoreDidFinishInitialImport = Notification.Name(rawValue: "iCloudUbiquitousStoreDidFinishInitialImport")
fileprivate static let iCloudUbiquitousStoreWillAddAccount = Notification.Name(rawValue: "iCloudUbiquitousStoreWillAddAccount")
fileprivate static let iCloudUbiquitousStoreDidAddAccount = Notification.Name(rawValue: "iCloudUbiquitousStoreDidAddAccount")
fileprivate static let iCloudUbiquitousStoreWillRemoveAccount = Notification.Name(rawValue: "iCloudUbiquitousStoreWillRemoveAccount")
fileprivate static let iCloudUbiquitousStoreDidRemoveAccount = Notification.Name(rawValue: "iCloudUbiquitousStoreDidRemoveAccount")
fileprivate static let iCloudUbiquitousStoreWillRemoveContent = Notification.Name(rawValue: "iCloudUbiquitousStoreWillRemoveContent")
fileprivate static let iCloudUbiquitousStoreDidRemoveContent = Notification.Name(rawValue: "iCloudUbiquitousStoreDidRemoveContent")
}
#endif

View File

@@ -69,7 +69,7 @@ public final class InMemoryStore: StorageInterface, DefaultInitializableStore {
/**
The options dictionary for the `NSPersistentStore`. For `InMemoryStore`s, this is always set to `nil`.
*/
public let storeOptions: [String: AnyObject]? = nil
public let storeOptions: [AnyHashable: Any]? = nil
/**
Do not call directly. Used by the `DataStack` internally.

View File

@@ -63,7 +63,7 @@ public final class LegacySQLiteStore: LocalStorage, DefaultInitializableStore {
*/
public init(fileName: String, configuration: String? = nil, mappingModelBundles: [Bundle] = Bundle.allBundles, localStorageOptions: LocalStorageOptions = nil) {
self.fileURL = try! LegacySQLiteStore.defaultRootDirectory.appendingPathComponent(
self.fileURL = LegacySQLiteStore.defaultRootDirectory.appendingPathComponent(
fileName,
isDirectory: false
)
@@ -99,7 +99,7 @@ public final class LegacySQLiteStore: LocalStorage, DefaultInitializableStore {
/**
The options dictionary for the specified `LocalStorageOptions`
*/
public func storeOptionsForOptions(_ options: LocalStorageOptions) -> [String: AnyObject]? {
public func storeOptionsForOptions(_ options: LocalStorageOptions) -> [AnyHashable: Any]? {
if options == .none {
@@ -126,7 +126,7 @@ public final class LegacySQLiteStore: LocalStorage, DefaultInitializableStore {
[NSSQLitePragmasOption: ["journal_mode": "WAL"]]
```
*/
public let storeOptions: [String: AnyObject]? = [NSSQLitePragmasOption: ["journal_mode": "WAL"]]
public let storeOptions: [AnyHashable: Any]? = [NSSQLitePragmasOption: ["journal_mode": "WAL"]]
/**
Do not call directly. Used by the `DataStack` internally.
@@ -184,12 +184,12 @@ public final class LegacySQLiteStore: LocalStorage, DefaultInitializableStore {
let fileManager = FileManager.default
do {
let temporaryFile = try URL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first!)
let temporaryFile = URL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first!)
.appendingPathComponent(Bundle.main.bundleIdentifier ?? "com.CoreStore.DataStack", isDirectory: true)
.appendingPathComponent("trash", isDirectory: true)
.appendingPathComponent(UUID().uuidString, isDirectory: false)
try fileManager.createDirectory(
at: try temporaryFile.deletingLastPathComponent(),
at: temporaryFile.deletingLastPathComponent(),
withIntermediateDirectories: true,
attributes: nil
)
@@ -217,13 +217,12 @@ public final class LegacySQLiteStore: LocalStorage, DefaultInitializableStore {
let systemDirectorySearchPath = FileManager.SearchPathDirectory.applicationSupportDirectory
#endif
return FileManager.default.urlsForDirectory(
systemDirectorySearchPath,
inDomains: .userDomainMask
).first!
return FileManager.default.urls(
for: systemDirectorySearchPath,
in: .userDomainMask).first!
}()
internal static let defaultFileURL = try! LegacySQLiteStore.defaultRootDirectory
internal static let defaultFileURL = LegacySQLiteStore.defaultRootDirectory
.appendingPathComponent(DataStack.applicationName, isDirectory: false)
.appendingPathExtension("sqlite")

View File

@@ -62,7 +62,7 @@ public final class SQLiteStore: LocalStorage, DefaultInitializableStore {
*/
public init(fileName: String, configuration: String? = nil, mappingModelBundles: [Bundle] = Bundle.allBundles, localStorageOptions: LocalStorageOptions = nil) {
self.fileURL = try! SQLiteStore.defaultRootDirectory
self.fileURL = SQLiteStore.defaultRootDirectory
.appendingPathComponent(fileName, isDirectory: false)
self.configuration = configuration
self.mappingModelBundles = mappingModelBundles
@@ -104,7 +104,7 @@ public final class SQLiteStore: LocalStorage, DefaultInitializableStore {
[NSSQLitePragmasOption: ["journal_mode": "WAL"]]
```
*/
public let storeOptions: [String: AnyObject]? = [NSSQLitePragmasOption: ["journal_mode": "WAL"]]
public let storeOptions: [AnyHashable: Any]? = [NSSQLitePragmasOption: ["journal_mode": "WAL"]]
/**
Do not call directly. Used by the `DataStack` internally.
@@ -143,7 +143,7 @@ public final class SQLiteStore: LocalStorage, DefaultInitializableStore {
/**
The options dictionary for the specified `LocalStorageOptions`
*/
public func storeOptionsForOptions(_ options: LocalStorageOptions) -> [String: AnyObject]? {
public func storeOptionsForOptions(_ options: LocalStorageOptions) -> [AnyHashable: Any]? {
if options == .none {
@@ -181,12 +181,12 @@ public final class SQLiteStore: LocalStorage, DefaultInitializableStore {
let fileManager = FileManager.default
do {
let temporaryFile = try URL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first!)
let temporaryFile = URL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first!)
.appendingPathComponent(Bundle.main.bundleIdentifier ?? "com.CoreStore.DataStack", isDirectory: true)
.appendingPathComponent("trash", isDirectory: true)
.appendingPathComponent(UUID().uuidString, isDirectory: false)
try fileManager.createDirectory(
at: try temporaryFile.deletingLastPathComponent(),
at: temporaryFile.deletingLastPathComponent(),
withIntermediateDirectories: true,
attributes: nil
)
@@ -214,10 +214,11 @@ public final class SQLiteStore: LocalStorage, DefaultInitializableStore {
let systemDirectorySearchPath = FileManager.SearchPathDirectory.applicationSupportDirectory
#endif
let defaultSystemDirectory = FileManager.default
.urlsForDirectory(systemDirectorySearchPath, inDomains: .userDomainMask).first!
let defaultSystemDirectory = FileManager.default.urls(
for: systemDirectorySearchPath,
in: .userDomainMask).first!
return try! defaultSystemDirectory.appendingPathComponent(
return defaultSystemDirectory.appendingPathComponent(
Bundle.main.bundleIdentifier ?? "com.CoreStore.DataStack",
isDirectory: true
)

View File

@@ -46,7 +46,7 @@ public protocol StorageInterface: class {
/**
The options dictionary for the `NSPersistentStore`
*/
var storeOptions: [String: AnyObject]? { get }
var storeOptions: [AnyHashable: Any]? { get }
// MARK: Internal (Do not call these directly)
@@ -153,7 +153,7 @@ public protocol LocalStorage: StorageInterface {
/**
The options dictionary for the specified `LocalStorageOptions`
*/
func storeOptionsForOptions(_ options: LocalStorageOptions) -> [String: AnyObject]?
func storeOptionsForOptions(_ options: LocalStorageOptions) -> [AnyHashable: Any]?
/**
Called by the `DataStack` 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)
@@ -237,7 +237,7 @@ public protocol CloudStorage: StorageInterface {
/**
The options dictionary for the specified `CloudStorageOptions`
*/
func storeOptionsForOptions(_ options: CloudStorageOptions) -> [String: AnyObject]?
func storeOptionsForOptions(_ options: CloudStorageOptions) -> [AnyHashable: Any]?
/**
Called by the `DataStack` 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. (Cloud stores for example, can set the NSPersistentStoreRemoveUbiquitousMetadataOption option before deleting)

View File

@@ -42,7 +42,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction {
public func commit(_ completion: @escaping (_ result: SaveResult) -> Void = { _ in }) {
CoreStore.assert(
self.transactionQueue.isCurrentExecutionContext(),
self.transactionQueue.cs_isCurrentExecutionContext(),
"Attempted to commit a \(cs_typeName(self)) outside its designated queue."
)
CoreStore.assert(
@@ -69,10 +69,10 @@ public final class AsynchronousDataTransaction: BaseDataTransaction {
- returns: a `SaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously
*/
@discardableResult
public func beginSynchronous(_ closure: (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {
public func beginSynchronous(_ closure: @escaping (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {
CoreStore.assert(
self.transactionQueue.isCurrentExecutionContext(),
self.transactionQueue.cs_isCurrentExecutionContext(),
"Attempted to begin a child transaction from a \(cs_typeName(self)) outside its designated queue."
)
CoreStore.assert(
@@ -188,7 +188,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction {
// MARK: Internal
internal init(mainContext: NSManagedObjectContext, queue: DispatchQueue, closure: (_ transaction: AsynchronousDataTransaction) -> Void) {
internal init(mainContext: NSManagedObjectContext, queue: DispatchQueue, closure: @escaping (_ transaction: AsynchronousDataTransaction) -> Void) {
self.closure = closure
@@ -199,7 +199,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction {
self.transactionQueue.async {
self.closure(transaction: self)
self.closure(self)
if !self.isCommitted && self.hasChanges {
CoreStore.log(
@@ -214,7 +214,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction {
self.transactionQueue.sync {
self.closure(transaction: self)
self.closure(self)
if !self.isCommitted && self.hasChanges {

View File

@@ -219,7 +219,7 @@ public /*abstract*/ class BaseDataTransaction {
public func insertedObjects() -> Set<NSManagedObject> {
CoreStore.assert(
self.transactionQueue.isCurrentExecutionContext(),
self.transactionQueue.cs_isCurrentExecutionContext(),
"Attempted to access inserted objects from a \(cs_typeName(self)) outside its designated queue."
)
CoreStore.assert(
@@ -239,7 +239,7 @@ public /*abstract*/ class BaseDataTransaction {
public func insertedObjects<T: NSManagedObject>(_ entity: T.Type) -> Set<T> {
CoreStore.assert(
self.transactionQueue.isCurrentExecutionContext(),
self.transactionQueue.cs_isCurrentExecutionContext(),
"Attempted to access inserted objects from a \(cs_typeName(self)) outside its designated queue."
)
CoreStore.assert(
@@ -258,7 +258,7 @@ public /*abstract*/ class BaseDataTransaction {
public func insertedObjectIDs() -> Set<NSManagedObjectID> {
CoreStore.assert(
self.transactionQueue.isCurrentExecutionContext(),
self.transactionQueue.cs_isCurrentExecutionContext(),
"Attempted to access inserted object IDs from a \(cs_typeName(self)) outside its designated queue."
)
CoreStore.assert(
@@ -278,7 +278,7 @@ public /*abstract*/ class BaseDataTransaction {
public func insertedObjectIDs<T: NSManagedObject>(_ entity: T.Type) -> Set<NSManagedObjectID> {
CoreStore.assert(
self.transactionQueue.isCurrentExecutionContext(),
self.transactionQueue.cs_isCurrentExecutionContext(),
"Attempted to access inserted object IDs from a \(cs_typeName(self)) outside its designated queue."
)
CoreStore.assert(
@@ -297,7 +297,7 @@ public /*abstract*/ class BaseDataTransaction {
public func updatedObjects() -> Set<NSManagedObject> {
CoreStore.assert(
self.transactionQueue.isCurrentExecutionContext(),
self.transactionQueue.cs_isCurrentExecutionContext(),
"Attempted to access updated objects from a \(cs_typeName(self)) outside its designated queue."
)
CoreStore.assert(
@@ -317,7 +317,7 @@ public /*abstract*/ class BaseDataTransaction {
public func updatedObjects<T: NSManagedObject>(_ entity: T.Type) -> Set<T> {
CoreStore.assert(
self.transactionQueue.isCurrentExecutionContext(),
self.transactionQueue.cs_isCurrentExecutionContext(),
"Attempted to access updated objects from a \(cs_typeName(self)) outside its designated queue."
)
CoreStore.assert(
@@ -336,7 +336,7 @@ public /*abstract*/ class BaseDataTransaction {
public func updatedObjectIDs() -> Set<NSManagedObjectID> {
CoreStore.assert(
self.transactionQueue.isCurrentExecutionContext(),
self.transactionQueue.cs_isCurrentExecutionContext(),
"Attempted to access updated object IDs from a \(cs_typeName(self)) outside its designated queue."
)
CoreStore.assert(
@@ -356,7 +356,7 @@ public /*abstract*/ class BaseDataTransaction {
public func updatedObjectIDs<T: NSManagedObject>(_ entity: T.Type) -> Set<NSManagedObjectID> {
CoreStore.assert(
self.transactionQueue.isCurrentExecutionContext(),
self.transactionQueue.cs_isCurrentExecutionContext(),
"Attempted to access updated object IDs from a \(cs_typeName(self)) outside its designated queue."
)
CoreStore.assert(
@@ -375,7 +375,7 @@ public /*abstract*/ class BaseDataTransaction {
public func deletedObjects() -> Set<NSManagedObject> {
CoreStore.assert(
self.transactionQueue.isCurrentExecutionContext(),
self.transactionQueue.cs_isCurrentExecutionContext(),
"Attempted to access deleted objects from a \(cs_typeName(self)) outside its designated queue."
)
CoreStore.assert(
@@ -395,7 +395,7 @@ public /*abstract*/ class BaseDataTransaction {
public func deletedObjects<T: NSManagedObject>(_ entity: T.Type) -> Set<T> {
CoreStore.assert(
self.transactionQueue.isCurrentExecutionContext(),
self.transactionQueue.cs_isCurrentExecutionContext(),
"Attempted to access deleted objects from a \(cs_typeName(self)) outside its designated queue."
)
CoreStore.assert(
@@ -415,7 +415,7 @@ public /*abstract*/ class BaseDataTransaction {
public func deletedObjectIDs() -> Set<NSManagedObjectID> {
CoreStore.assert(
self.transactionQueue.isCurrentExecutionContext(),
self.transactionQueue.cs_isCurrentExecutionContext(),
"Attempted to access deleted object IDs from a \(cs_typeName(self)) outside its designated queue."
)
CoreStore.assert(
@@ -435,7 +435,7 @@ public /*abstract*/ class BaseDataTransaction {
public func deletedObjectIDs<T: NSManagedObject>(_ entity: T.Type) -> Set<NSManagedObjectID> {
CoreStore.assert(
self.transactionQueue.isCurrentExecutionContext(),
self.transactionQueue.cs_isCurrentExecutionContext(),
"Attempted to access deleted object IDs from a \(cs_typeName(self)) outside its designated queue."
)
CoreStore.assert(
@@ -484,6 +484,6 @@ public /*abstract*/ class BaseDataTransaction {
internal func isRunningInAllowedQueue() -> Bool {
return self.bypassesQueueing || self.transactionQueue.isCurrentExecutionContext()
return self.bypassesQueueing || self.transactionQueue.cs_isCurrentExecutionContext()
}
}

View File

@@ -35,7 +35,7 @@ public extension CoreStore {
- parameter closure: the block where creates, updates, and deletes can be made to the transaction. Transaction blocks are executed serially in a background queue, and all changes are made from a concurrent `NSManagedObjectContext`.
*/
public static func beginAsynchronous(_ closure: (_ transaction: AsynchronousDataTransaction) -> Void) {
public static func beginAsynchronous(_ closure: @escaping (_ transaction: AsynchronousDataTransaction) -> Void) {
self.defaultStack.beginAsynchronous(closure)
}
@@ -47,7 +47,7 @@ public extension CoreStore {
- returns: a `SaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously
*/
@discardableResult
public static func beginSynchronous(_ closure: (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {
public static func beginSynchronous(_ closure: @escaping (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {
return self.defaultStack.beginSynchronous(closure)
}

View File

@@ -36,7 +36,7 @@ public extension DataStack {
- parameter closure: the block where creates, updates, and deletes can be made to the transaction. Transaction blocks are executed serially in a background queue, and all changes are made from a concurrent `NSManagedObjectContext`.
*/
public func beginAsynchronous(_ closure: (_ transaction: AsynchronousDataTransaction) -> Void) {
public func beginAsynchronous(_ closure: @escaping (_ transaction: AsynchronousDataTransaction) -> Void) {
AsynchronousDataTransaction(
mainContext: self.rootSavingContext,
@@ -51,7 +51,7 @@ public extension DataStack {
- returns: a `SaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously
*/
@discardableResult
public func beginSynchronous(_ closure: (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {
public func beginSynchronous(_ closure: @escaping (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {
return SynchronousDataTransaction(
mainContext: self.rootSavingContext,
@@ -69,9 +69,9 @@ public extension DataStack {
return UnsafeDataTransaction(
mainContext: self.rootSavingContext,
queue: .createSerial(
"com.coreStore.dataStack.unsafeTransactionQueue",
targetQueue: .userInitiated
queue: DispatchQueue(
serialWith: "com.coreStore.dataStack.unsafeTransactionQueue",
qos: .userInitiated
),
supportsUndo: supportsUndo
)

View File

@@ -50,7 +50,7 @@ public extension NSManagedObject {
@nonobjc
internal class func createInContext(_ context: NSManagedObjectContext) -> Self {
return self.`init`(entity:insertInto:)(
return self.init(
entity: context.entityDescriptionForEntityType(self)!,
insertInto: context
)

View File

@@ -42,7 +42,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
public func commitAndWait() -> SaveResult {
CoreStore.assert(
self.transactionQueue.isCurrentExecutionContext(),
self.transactionQueue.cs_isCurrentExecutionContext(),
"Attempted to commit a \(cs_typeName(self)) outside its designated queue."
)
CoreStore.assert(
@@ -64,10 +64,10 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
- returns: a `SaveResult` value indicating success or failure, or `nil` if the transaction was not comitted synchronously
*/
@discardableResult
public func beginSynchronous(_ closure: (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {
public func beginSynchronous(_ closure: @escaping (_ transaction: SynchronousDataTransaction) -> Void) -> SaveResult? {
CoreStore.assert(
self.transactionQueue.isCurrentExecutionContext(),
self.transactionQueue.cs_isCurrentExecutionContext(),
"Attempted to begin a child transaction from a \(cs_typeName(self)) outside its designated queue."
)
CoreStore.assert(
@@ -183,7 +183,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
// MARK: Internal
internal init(mainContext: NSManagedObjectContext, queue: DispatchQueue, closure: (_ transaction: SynchronousDataTransaction) -> Void) {
internal init(mainContext: NSManagedObjectContext, queue: DispatchQueue, closure: @escaping (_ transaction: SynchronousDataTransaction) -> Void) {
self.closure = closure
@@ -194,7 +194,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
self.transactionQueue.sync {
self.closure(transaction: self)
self.closure(self)
if !self.isCommitted && self.hasChanges {