goodbye ObjectiveC

This commit is contained in:
John Estropia
2021-09-22 20:04:58 +09:00
parent bf10f4668c
commit 9a026afe40
110 changed files with 1060 additions and 9816 deletions

View File

@@ -29,112 +29,62 @@ import CoreData
// MARK: - CSWhere
/**
The `CSWhere` serves as the Objective-C bridging type for `Where`.
- SeeAlso: `Where`
*/
@available(*, unavailable, message: "CoreStore Objective-C is now obsoleted in preparation for Swift concurrency.")
@objc
public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClause {
/**
The internal `NSPredicate` instance for the `Where` clause
*/
@objc
public var predicate: NSPredicate {
return self.bridgeToSwift.predicate
fatalError()
}
/**
Initializes a `CSWhere` clause with a predicate that always evaluates to the specified boolean value
```
MyPersonEntity *people = [transaction
fetchAllFrom:CSFromClass([MyPersonEntity class])
fetchClauses:@[CSWhereValue(YES)]]];
```
- parameter value: the boolean value for the predicate
*/
@objc
public convenience init(value: Bool) {
self.init(Where(value))
fatalError()
}
/**
Initializes a `CSWhere` clause with a predicate using the specified string format and arguments
```
NSPredicate *predicate = // ...
MyPersonEntity *people = [transaction
fetchAllFrom:CSFromClass([MyPersonEntity class])
fetchClauses:@[CSWherePredicate(predicate)]];
```
- parameter format: the format string for the predicate
- parameter argumentArray: the arguments for `format`
*/
@objc
public convenience init(format: String, argumentArray: [NSObject]?) {
self.init(Where(format, argumentArray: argumentArray))
fatalError()
}
/**
Initializes a `CSWhere` clause that compares equality
- parameter keyPath: the keyPath to compare with
- parameter value: the arguments for the `==` operator
*/
@objc
public convenience init(keyPath: KeyPathString, isEqualTo value: CoreDataNativeType?) {
self.init(value == nil || value is NSNull
? Where("\(keyPath) == nil")
: Where("\(keyPath) == %@", value!))
fatalError()
}
/**
Initializes a `CSWhere` clause that compares membership
- parameter keyPath: the keyPath to compare with
- parameter list: the array to check membership of
*/
@objc
public convenience init(keyPath: KeyPathString, isMemberOf list: [CoreDataNativeType]) {
self.init(Where("\(keyPath) IN %@", list as NSArray))
fatalError()
}
/**
Initializes a `CSWhere` clause with an `NSPredicate`
- parameter predicate: the `NSPredicate` for the fetch or query
*/
@objc
public convenience init(predicate: NSPredicate) {
self.init(Where(predicate))
fatalError()
}
// MARK: NSObject
public override var hash: Int {
return self.bridgeToSwift.hashValue
fatalError()
}
public override func isEqual(_ object: Any?) -> Bool {
guard let object = object as? CSWhere else {
return false
}
return self.bridgeToSwift == object.bridgeToSwift
fatalError()
}
public override var description: String {
return "(\(String(reflecting: Self.self))) \(self.bridgeToSwift.coreStoreDumpString)"
fatalError()
}
@@ -142,8 +92,8 @@ public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
@objc
public func applyToFetchRequest(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) {
self.bridgeToSwift.applyToFetchRequest(fetchRequest)
fatalError()
}
@@ -152,29 +102,21 @@ public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
public let bridgeToSwift: Where<NSManagedObject>
public init<O: NSManagedObject>(_ swiftValue: Where<O>) {
self.bridgeToSwift = swiftValue.downcast()
super.init()
fatalError()
}
}
// MARK: - Where
@available(*, unavailable, message: "CoreStore Objective-C is now obsoleted in preparation for Swift concurrency.")
extension Where where O: NSManagedObject {
// MARK: CoreStoreSwiftType
public var bridgeToObjectiveC: CSWhere {
return CSWhere(self)
}
// MARK: FilePrivate
fileprivate func downcast() -> Where<NSManagedObject> {
return Where<NSManagedObject>(self.predicate)
fatalError()
}
}