mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-29 13:51:48 +02:00
Merge branch 'develop' into corestore2_develop
# Conflicts: # CoreStore.podspec # CoreStore.xcodeproj/project.pbxproj # CoreStore/Setting Up/DataStack.swift # Sources/Info.plist
This commit is contained in:
@@ -87,6 +87,11 @@
|
|||||||
B51BE06A1B47FC4B0069F532 /* NSManagedObjectModel+Setup.swift in Sources */ = {isa = PBXBuildFile; fileRef = B51BE0691B47FC4B0069F532 /* NSManagedObjectModel+Setup.swift */; };
|
B51BE06A1B47FC4B0069F532 /* NSManagedObjectModel+Setup.swift in Sources */ = {isa = PBXBuildFile; fileRef = B51BE0691B47FC4B0069F532 /* NSManagedObjectModel+Setup.swift */; };
|
||||||
B5202CFA1C04688100DED140 /* NSFetchedResultsController+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5202CF91C04688100DED140 /* NSFetchedResultsController+Convenience.swift */; };
|
B5202CFA1C04688100DED140 /* NSFetchedResultsController+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5202CF91C04688100DED140 /* NSFetchedResultsController+Convenience.swift */; };
|
||||||
B5202CFD1C046E8400DED140 /* NSFetchedResultsController+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5202CF91C04688100DED140 /* NSFetchedResultsController+Convenience.swift */; };
|
B5202CFD1C046E8400DED140 /* NSFetchedResultsController+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5202CF91C04688100DED140 /* NSFetchedResultsController+Convenience.swift */; };
|
||||||
|
B52661401CADD585007B85D9 /* CoreStoreFetchRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B526613F1CADD585007B85D9 /* CoreStoreFetchRequest.swift */; };
|
||||||
|
B52661411CADD585007B85D9 /* CoreStoreFetchRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B526613F1CADD585007B85D9 /* CoreStoreFetchRequest.swift */; };
|
||||||
|
B52661421CADD585007B85D9 /* CoreStoreFetchRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B526613F1CADD585007B85D9 /* CoreStoreFetchRequest.swift */; };
|
||||||
|
B52661431CADD585007B85D9 /* CoreStoreFetchRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B526613F1CADD585007B85D9 /* CoreStoreFetchRequest.swift */; };
|
||||||
|
B52661441CADD585007B85D9 /* CoreStoreFetchRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B526613F1CADD585007B85D9 /* CoreStoreFetchRequest.swift */; };
|
||||||
B52DD17E1BE1F8CD00949AFE /* CoreStore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B52DD1741BE1F8CC00949AFE /* CoreStore.framework */; };
|
B52DD17E1BE1F8CD00949AFE /* CoreStore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B52DD1741BE1F8CC00949AFE /* CoreStore.framework */; };
|
||||||
B52DD1911BE1F8EB00949AFE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5548CD51BD65AE00077652A /* Foundation.framework */; };
|
B52DD1911BE1F8EB00949AFE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5548CD51BD65AE00077652A /* Foundation.framework */; };
|
||||||
B52DD1921BE1F8F000949AFE /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5548CD71BD65AE50077652A /* CoreData.framework */; };
|
B52DD1921BE1F8F000949AFE /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5548CD71BD65AE50077652A /* CoreData.framework */; };
|
||||||
@@ -416,6 +421,7 @@
|
|||||||
B51BE0691B47FC4B0069F532 /* NSManagedObjectModel+Setup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSManagedObjectModel+Setup.swift"; sourceTree = "<group>"; };
|
B51BE0691B47FC4B0069F532 /* NSManagedObjectModel+Setup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSManagedObjectModel+Setup.swift"; sourceTree = "<group>"; };
|
||||||
B51F25991C5747DD0083A5DD /* DataStack+iCloud.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DataStack+iCloud.swift"; sourceTree = "<group>"; };
|
B51F25991C5747DD0083A5DD /* DataStack+iCloud.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DataStack+iCloud.swift"; sourceTree = "<group>"; };
|
||||||
B5202CF91C04688100DED140 /* NSFetchedResultsController+Convenience.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSFetchedResultsController+Convenience.swift"; sourceTree = "<group>"; };
|
B5202CF91C04688100DED140 /* NSFetchedResultsController+Convenience.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSFetchedResultsController+Convenience.swift"; sourceTree = "<group>"; };
|
||||||
|
B526613F1CADD585007B85D9 /* CoreStoreFetchRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreStoreFetchRequest.swift; sourceTree = "<group>"; };
|
||||||
B52DD1741BE1F8CC00949AFE /* CoreStore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CoreStore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
B52DD1741BE1F8CC00949AFE /* CoreStore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CoreStore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
B52DD17D1BE1F8CC00949AFE /* CoreStoreTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CoreStoreTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
B52DD17D1BE1F8CC00949AFE /* CoreStoreTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CoreStoreTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
B546F9521C95529D00D5AC55 /* LocalStorageOptions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocalStorageOptions.swift; sourceTree = "<group>"; };
|
B546F9521C95529D00D5AC55 /* LocalStorageOptions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocalStorageOptions.swift; sourceTree = "<group>"; };
|
||||||
@@ -827,6 +833,7 @@
|
|||||||
B5FAD6AB1B51285300714891 /* MigrationManager.swift */,
|
B5FAD6AB1B51285300714891 /* MigrationManager.swift */,
|
||||||
B5E84F2B1AFF849C0064E85B /* NotificationObserver.swift */,
|
B5E84F2B1AFF849C0064E85B /* NotificationObserver.swift */,
|
||||||
B59D5C211B5BA34B00453479 /* NSFileManager+Setup.swift */,
|
B59D5C211B5BA34B00453479 /* NSFileManager+Setup.swift */,
|
||||||
|
B526613F1CADD585007B85D9 /* CoreStoreFetchRequest.swift */,
|
||||||
B5E84F2C1AFF849C0064E85B /* NSManagedObjectContext+CoreStore.swift */,
|
B5E84F2C1AFF849C0064E85B /* NSManagedObjectContext+CoreStore.swift */,
|
||||||
B5E84F351AFF85470064E85B /* NSManagedObjectContext+Querying.swift */,
|
B5E84F351AFF85470064E85B /* NSManagedObjectContext+Querying.swift */,
|
||||||
B5E84F321AFF85470064E85B /* NSManagedObjectContext+Setup.swift */,
|
B5E84F321AFF85470064E85B /* NSManagedObjectContext+Setup.swift */,
|
||||||
@@ -1186,6 +1193,7 @@
|
|||||||
B5E84F111AFF847B0064E85B /* Select.swift in Sources */,
|
B5E84F111AFF847B0064E85B /* Select.swift in Sources */,
|
||||||
B5FE4DA21C8481E100FA6A91 /* StorageInterface.swift in Sources */,
|
B5FE4DA21C8481E100FA6A91 /* StorageInterface.swift in Sources */,
|
||||||
B50392F91C478FF3009900CA /* NSManagedObject+Transaction.swift in Sources */,
|
B50392F91C478FF3009900CA /* NSManagedObject+Transaction.swift in Sources */,
|
||||||
|
B52661401CADD585007B85D9 /* CoreStoreFetchRequest.swift in Sources */,
|
||||||
B5202CFA1C04688100DED140 /* NSFetchedResultsController+Convenience.swift in Sources */,
|
B5202CFA1C04688100DED140 /* NSFetchedResultsController+Convenience.swift in Sources */,
|
||||||
B5E84EE11AFF84500064E85B /* SetupResult.swift in Sources */,
|
B5E84EE11AFF84500064E85B /* SetupResult.swift in Sources */,
|
||||||
B5E84F251AFF84860064E85B /* ObjectObserver.swift in Sources */,
|
B5E84F251AFF84860064E85B /* ObjectObserver.swift in Sources */,
|
||||||
@@ -1273,6 +1281,7 @@
|
|||||||
B5FE4DA81C84FB4400FA6A91 /* InMemoryStore.swift in Sources */,
|
B5FE4DA81C84FB4400FA6A91 /* InMemoryStore.swift in Sources */,
|
||||||
82BA18B41C4BBD3900A0916E /* BaseDataTransaction+Importing.swift in Sources */,
|
82BA18B41C4BBD3900A0916E /* BaseDataTransaction+Importing.swift in Sources */,
|
||||||
82BA18CA1C4BBD5900A0916E /* MigrationResult.swift in Sources */,
|
82BA18CA1C4BBD5900A0916E /* MigrationResult.swift in Sources */,
|
||||||
|
B52661421CADD585007B85D9 /* CoreStoreFetchRequest.swift in Sources */,
|
||||||
82BA18C11C4BBD5300A0916E /* CoreStore+Observing.swift in Sources */,
|
82BA18C11C4BBD5300A0916E /* CoreStore+Observing.swift in Sources */,
|
||||||
82BA18BC1C4BBD4A00A0916E /* OrderBy.swift in Sources */,
|
82BA18BC1C4BBD4A00A0916E /* OrderBy.swift in Sources */,
|
||||||
82BA18B01C4BBD3100A0916E /* NSManagedObject+Transaction.swift in Sources */,
|
82BA18B01C4BBD3100A0916E /* NSManagedObject+Transaction.swift in Sources */,
|
||||||
@@ -1358,6 +1367,7 @@
|
|||||||
B52DD1C71BE1F94600949AFE /* NSManagedObjectContext+Querying.swift in Sources */,
|
B52DD1C71BE1F94600949AFE /* NSManagedObjectContext+Querying.swift in Sources */,
|
||||||
B52DD1C81BE1F94600949AFE /* NSManagedObjectContext+Setup.swift in Sources */,
|
B52DD1C81BE1F94600949AFE /* NSManagedObjectContext+Setup.swift in Sources */,
|
||||||
B52DD1C31BE1F94600949AFE /* NotificationObserver.swift in Sources */,
|
B52DD1C31BE1F94600949AFE /* NotificationObserver.swift in Sources */,
|
||||||
|
B52661441CADD585007B85D9 /* CoreStoreFetchRequest.swift in Sources */,
|
||||||
B52DD1A81BE1F93200949AFE /* DataStack+Querying.swift in Sources */,
|
B52DD1A81BE1F93200949AFE /* DataStack+Querying.swift in Sources */,
|
||||||
B52DD1BC1BE1F94000949AFE /* MigrationResult.swift in Sources */,
|
B52DD1BC1BE1F94000949AFE /* MigrationResult.swift in Sources */,
|
||||||
B52DD19D1BE1F92C00949AFE /* BaseDataTransaction.swift in Sources */,
|
B52DD19D1BE1F92C00949AFE /* BaseDataTransaction.swift in Sources */,
|
||||||
@@ -1434,6 +1444,7 @@
|
|||||||
B5FE4DA91C84FB4400FA6A91 /* InMemoryStore.swift in Sources */,
|
B5FE4DA91C84FB4400FA6A91 /* InMemoryStore.swift in Sources */,
|
||||||
B56321AF1BD6521C006C9394 /* NSFileManager+Setup.swift in Sources */,
|
B56321AF1BD6521C006C9394 /* NSFileManager+Setup.swift in Sources */,
|
||||||
B50392FA1C47963F009900CA /* NSManagedObject+Transaction.swift in Sources */,
|
B50392FA1C47963F009900CA /* NSManagedObject+Transaction.swift in Sources */,
|
||||||
|
B52661431CADD585007B85D9 /* CoreStoreFetchRequest.swift in Sources */,
|
||||||
B56321971BD65216006C9394 /* Select.swift in Sources */,
|
B56321971BD65216006C9394 /* Select.swift in Sources */,
|
||||||
B56321AB1BD6521C006C9394 /* FetchedResultsControllerDelegate.swift in Sources */,
|
B56321AB1BD6521C006C9394 /* FetchedResultsControllerDelegate.swift in Sources */,
|
||||||
B56321821BD65216006C9394 /* SetupResult.swift in Sources */,
|
B56321821BD65216006C9394 /* SetupResult.swift in Sources */,
|
||||||
@@ -1499,6 +1510,7 @@
|
|||||||
B5D9E2F71CA2C317007A9D52 /* DataStack+Querying.swift in Sources */,
|
B5D9E2F71CA2C317007A9D52 /* DataStack+Querying.swift in Sources */,
|
||||||
B5D9E2F81CA2C317007A9D52 /* SectionBy.swift in Sources */,
|
B5D9E2F81CA2C317007A9D52 /* SectionBy.swift in Sources */,
|
||||||
B5D9E2F91CA2C317007A9D52 /* NSManagedObjectContext+Transaction.swift in Sources */,
|
B5D9E2F91CA2C317007A9D52 /* NSManagedObjectContext+Transaction.swift in Sources */,
|
||||||
|
B52661411CADD585007B85D9 /* CoreStoreFetchRequest.swift in Sources */,
|
||||||
B5D9E2FA1CA2C317007A9D52 /* UnsafeDataTransaction+Observing.swift in Sources */,
|
B5D9E2FA1CA2C317007A9D52 /* UnsafeDataTransaction+Observing.swift in Sources */,
|
||||||
B5D9E2FB1CA2C317007A9D52 /* MigrationChain.swift in Sources */,
|
B5D9E2FB1CA2C317007A9D52 /* MigrationChain.swift in Sources */,
|
||||||
B5D9E2FC1CA2C317007A9D52 /* Tweak.swift in Sources */,
|
B5D9E2FC1CA2C317007A9D52 /* Tweak.swift in Sources */,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ private struct Static {
|
|||||||
SQLiteStore(
|
SQLiteStore(
|
||||||
fileName: "TimeZoneDemo.sqlite",
|
fileName: "TimeZoneDemo.sqlite",
|
||||||
configuration: "FetchingAndQueryingDemo",
|
configuration: "FetchingAndQueryingDemo",
|
||||||
resetStoreOnModelMismatch: true
|
localStorageOptions: .RecreateStoreOnModelMismatch
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ private struct Static {
|
|||||||
SQLiteStore(
|
SQLiteStore(
|
||||||
fileName: "ColorsDemo.sqlite",
|
fileName: "ColorsDemo.sqlite",
|
||||||
configuration: "ObservingDemo",
|
configuration: "ObservingDemo",
|
||||||
resetStoreOnModelMismatch: true
|
localStorageOptions: .RecreateStoreOnModelMismatch
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class CustomLoggerViewController: UIViewController, CoreStoreLogger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleError(error error: NSError, message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString) {
|
func log(error error: CoreStoreError, message: String, fileName: StaticString, lineNumber: Int, functionName: StaticString) {
|
||||||
|
|
||||||
GCDQueue.Main.async { [weak self] in
|
GCDQueue.Main.async { [weak self] in
|
||||||
|
|
||||||
|
|||||||
@@ -22,14 +22,14 @@ private struct Static {
|
|||||||
SQLiteStore(
|
SQLiteStore(
|
||||||
fileName: "AccountsDemo_FB_Male.sqlite",
|
fileName: "AccountsDemo_FB_Male.sqlite",
|
||||||
configuration: maleConfiguration,
|
configuration: maleConfiguration,
|
||||||
resetStoreOnModelMismatch: true
|
localStorageOptions: .RecreateStoreOnModelMismatch
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
try! dataStack.addStorageAndWait(
|
try! dataStack.addStorageAndWait(
|
||||||
SQLiteStore(
|
SQLiteStore(
|
||||||
fileName: "AccountsDemo_FB_Female.sqlite",
|
fileName: "AccountsDemo_FB_Female.sqlite",
|
||||||
configuration: femaleConfiguration,
|
configuration: femaleConfiguration,
|
||||||
resetStoreOnModelMismatch: true
|
localStorageOptions: .RecreateStoreOnModelMismatch
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -60,14 +60,14 @@ private struct Static {
|
|||||||
SQLiteStore(
|
SQLiteStore(
|
||||||
fileName: "AccountsDemo_TW_Male.sqlite",
|
fileName: "AccountsDemo_TW_Male.sqlite",
|
||||||
configuration: maleConfiguration,
|
configuration: maleConfiguration,
|
||||||
resetStoreOnModelMismatch: true
|
localStorageOptions: .RecreateStoreOnModelMismatch
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
try! dataStack.addStorageAndWait(
|
try! dataStack.addStorageAndWait(
|
||||||
SQLiteStore(
|
SQLiteStore(
|
||||||
fileName: "AccountsDemo_TW_Female.sqlite",
|
fileName: "AccountsDemo_TW_Female.sqlite",
|
||||||
configuration: femaleConfiguration,
|
configuration: femaleConfiguration,
|
||||||
resetStoreOnModelMismatch: true
|
localStorageOptions: .RecreateStoreOnModelMismatch
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ private struct Static {
|
|||||||
SQLiteStore(
|
SQLiteStore(
|
||||||
fileName: "PlaceDemo.sqlite",
|
fileName: "PlaceDemo.sqlite",
|
||||||
configuration: "TransactionsDemo",
|
configuration: "TransactionsDemo",
|
||||||
resetStoreOnModelMismatch: true
|
localStorageOptions: .RecreateStoreOnModelMismatch
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
43
Sources/Internal/CoreStoreFetchRequest.swift
Normal file
43
Sources/Internal/CoreStoreFetchRequest.swift
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
//
|
||||||
|
// CoreStoreFetchRequest.swift
|
||||||
|
// CoreStore
|
||||||
|
//
|
||||||
|
// Copyright © 2016 John Rommel Estropia
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
// SOFTWARE.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: - CoreStoreFetchRequest
|
||||||
|
|
||||||
|
// Bugfix for NSFetchRequest messing up memory management for `affectedStores`
|
||||||
|
// http://stackoverflow.com/questions/14396375/nsfetchedresultscontroller-crashes-in-ios-6-if-affectedstores-is-specified
|
||||||
|
internal final class CoreStoreFetchRequest: NSFetchRequest {
|
||||||
|
|
||||||
|
override var affectedStores: [NSPersistentStore]? {
|
||||||
|
|
||||||
|
get { return self.safeAffectedStores }
|
||||||
|
set { self.safeAffectedStores = newValue }
|
||||||
|
}
|
||||||
|
|
||||||
|
private var safeAffectedStores: [NSPersistentStore]?
|
||||||
|
}
|
||||||
@@ -76,7 +76,7 @@ internal extension NSManagedObjectContext {
|
|||||||
|
|
||||||
internal func fetchOne<T: NSManagedObject>(from: From<T>, _ fetchClauses: [FetchClause]) -> T? {
|
internal func fetchOne<T: NSManagedObject>(from: From<T>, _ fetchClauses: [FetchClause]) -> T? {
|
||||||
|
|
||||||
let fetchRequest = NSFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
from.applyToFetchRequest(fetchRequest, context: self)
|
from.applyToFetchRequest(fetchRequest, context: self)
|
||||||
|
|
||||||
fetchRequest.fetchLimit = 1
|
fetchRequest.fetchLimit = 1
|
||||||
@@ -119,7 +119,7 @@ internal extension NSManagedObjectContext {
|
|||||||
|
|
||||||
internal func fetchAll<T: NSManagedObject>(from: From<T>, _ fetchClauses: [FetchClause]) -> [T]? {
|
internal func fetchAll<T: NSManagedObject>(from: From<T>, _ fetchClauses: [FetchClause]) -> [T]? {
|
||||||
|
|
||||||
let fetchRequest = NSFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
from.applyToFetchRequest(fetchRequest, context: self)
|
from.applyToFetchRequest(fetchRequest, context: self)
|
||||||
|
|
||||||
fetchRequest.fetchLimit = 0
|
fetchRequest.fetchLimit = 0
|
||||||
@@ -162,7 +162,7 @@ internal extension NSManagedObjectContext {
|
|||||||
|
|
||||||
internal func fetchCount<T: NSManagedObject>(from: From<T>, _ fetchClauses: [FetchClause]) -> Int? {
|
internal func fetchCount<T: NSManagedObject>(from: From<T>, _ fetchClauses: [FetchClause]) -> Int? {
|
||||||
|
|
||||||
let fetchRequest = NSFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
from.applyToFetchRequest(fetchRequest, context: self)
|
from.applyToFetchRequest(fetchRequest, context: self)
|
||||||
|
|
||||||
for clause in fetchClauses {
|
for clause in fetchClauses {
|
||||||
@@ -195,7 +195,7 @@ internal extension NSManagedObjectContext {
|
|||||||
|
|
||||||
internal func fetchObjectID<T: NSManagedObject>(from: From<T>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? {
|
internal func fetchObjectID<T: NSManagedObject>(from: From<T>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? {
|
||||||
|
|
||||||
let fetchRequest = NSFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
from.applyToFetchRequest(fetchRequest, context: self)
|
from.applyToFetchRequest(fetchRequest, context: self)
|
||||||
|
|
||||||
fetchRequest.fetchLimit = 1
|
fetchRequest.fetchLimit = 1
|
||||||
@@ -238,7 +238,7 @@ internal extension NSManagedObjectContext {
|
|||||||
|
|
||||||
internal func fetchObjectIDs<T: NSManagedObject>(from: From<T>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? {
|
internal func fetchObjectIDs<T: NSManagedObject>(from: From<T>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? {
|
||||||
|
|
||||||
let fetchRequest = NSFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
from.applyToFetchRequest(fetchRequest, context: self)
|
from.applyToFetchRequest(fetchRequest, context: self)
|
||||||
|
|
||||||
fetchRequest.fetchLimit = 0
|
fetchRequest.fetchLimit = 0
|
||||||
@@ -281,7 +281,7 @@ internal extension NSManagedObjectContext {
|
|||||||
|
|
||||||
internal func deleteAll<T: NSManagedObject>(from: From<T>, _ deleteClauses: [DeleteClause]) -> Int? {
|
internal func deleteAll<T: NSManagedObject>(from: From<T>, _ deleteClauses: [DeleteClause]) -> Int? {
|
||||||
|
|
||||||
let fetchRequest = NSFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
from.applyToFetchRequest(fetchRequest, context: self)
|
from.applyToFetchRequest(fetchRequest, context: self)
|
||||||
|
|
||||||
fetchRequest.fetchLimit = 0
|
fetchRequest.fetchLimit = 0
|
||||||
@@ -334,7 +334,7 @@ internal extension NSManagedObjectContext {
|
|||||||
|
|
||||||
internal func queryValue<T: NSManagedObject, U: SelectValueResultType>(from: From<T>, _ selectClause: Select<U>, _ queryClauses: [QueryClause]) -> U? {
|
internal func queryValue<T: NSManagedObject, U: SelectValueResultType>(from: From<T>, _ selectClause: Select<U>, _ queryClauses: [QueryClause]) -> U? {
|
||||||
|
|
||||||
let fetchRequest = NSFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
from.applyToFetchRequest(fetchRequest, context: self)
|
from.applyToFetchRequest(fetchRequest, context: self)
|
||||||
|
|
||||||
fetchRequest.fetchLimit = 0
|
fetchRequest.fetchLimit = 0
|
||||||
@@ -383,7 +383,7 @@ internal extension NSManagedObjectContext {
|
|||||||
|
|
||||||
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]) -> [[NSString: AnyObject]]? {
|
||||||
|
|
||||||
let fetchRequest = NSFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
from.applyToFetchRequest(fetchRequest, context: self)
|
from.applyToFetchRequest(fetchRequest, context: self)
|
||||||
|
|
||||||
fetchRequest.fetchLimit = 0
|
fetchRequest.fetchLimit = 0
|
||||||
|
|||||||
@@ -991,7 +991,7 @@ public final class ListMonitor<T: NSManagedObject> {
|
|||||||
|
|
||||||
private init(context: NSManagedObjectContext, transactionQueue: GCDQueue, from: From<T>, sectionBy: SectionBy?, fetchClauses: [FetchClause], createAsynchronously: ((ListMonitor<T>) -> Void)?) {
|
private init(context: NSManagedObjectContext, transactionQueue: GCDQueue, from: From<T>, sectionBy: SectionBy?, fetchClauses: [FetchClause], createAsynchronously: ((ListMonitor<T>) -> Void)?) {
|
||||||
|
|
||||||
let fetchRequest = NSFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
fetchRequest.fetchLimit = 0
|
fetchRequest.fetchLimit = 0
|
||||||
fetchRequest.resultType = .ManagedObjectResultType
|
fetchRequest.resultType = .ManagedObjectResultType
|
||||||
fetchRequest.fetchBatchSize = 20
|
fetchRequest.fetchBatchSize = 20
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ public final class ObjectMonitor<T: NSManagedObject> {
|
|||||||
|
|
||||||
private init(context: NSManagedObjectContext, object: T) {
|
private init(context: NSManagedObjectContext, object: T) {
|
||||||
|
|
||||||
let fetchRequest = NSFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
fetchRequest.entity = object.entity
|
fetchRequest.entity = object.entity
|
||||||
fetchRequest.fetchLimit = 0
|
fetchRequest.fetchLimit = 0
|
||||||
fetchRequest.resultType = .ManagedObjectResultType
|
fetchRequest.resultType = .ManagedObjectResultType
|
||||||
|
|||||||
@@ -414,7 +414,16 @@ public final class DataStack {
|
|||||||
deinit {
|
deinit {
|
||||||
|
|
||||||
let coordinator = self.coordinator
|
let coordinator = self.coordinator
|
||||||
coordinator.persistentStores.forEach { _ = try? coordinator.removePersistentStore($0) }
|
coordinator.performAsynchronously {
|
||||||
|
|
||||||
|
withExtendedLifetime(coordinator) { coordinator in
|
||||||
|
|
||||||
|
coordinator.persistentStores.forEach {
|
||||||
|
|
||||||
|
_ = try? coordinator.removePersistentStore($0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user