Compare commits

...

26 Commits
5.0.0 ... 5.2.0

Author SHA1 Message Date
John Estropia
f25879b6fe fix compile error on tvOS and watchOS 2018-08-09 21:04:09 +09:00
John Estropia
8fa3109e91 version bump 2018-08-09 20:45:46 +09:00
John Estropia
808e8ff97a stabilize NSProgress when lightweight migration falls back to InferredMappingModel 2018-08-09 18:18:21 +09:00
John Estropia
30685d4355 Use InferredMappingModel in case lightweight migration fails for some reason 2018-08-09 02:09:54 +09:00
John Estropia
7152962026 revert 2018-08-09 01:39:16 +09:00
John Estropia
91735e38d1 Fix issue where CoreStoreObjects nested in a type is mismatching classnames before migration 2018-08-08 23:52:47 +09:00
John Estropia
333a50ad9e Merge pull request #256 from vGubriienko/demo-fix
Fixed issue with brightness observing in the Demo
2018-08-03 17:44:40 +09:00
John Rommel Estropia
b7a602fc67 iOS 11 Core Data changes 2018-07-29 23:33:51 +09:00
Viktor Gubriienko
2ff7ecef96 Fixed issue with brightness observing in the Demo 2018-06-12 17:53:00 +03:00
John Rommel Estropia
e3f9139304 version bump 2018-06-10 11:52:47 +09:00
John Rommel Estropia
4aa461872f specify swift version in podspec 2018-06-10 11:47:03 +09:00
John Rommel Estropia
3d43314076 update readme 2018-04-14 09:05:13 +09:00
John Rommel Estropia
7b1075b759 support compound indexes and unique constraints on CoreStore properties 2018-03-17 23:56:42 +09:00
John Rommel Estropia
0c29e07ddb support allowsExternalBinaryDataStorage option on Transformable CoreStoreObject properties 2018-03-17 23:56:01 +09:00
John Rommel Estropia
ce91cf22f9 Swift 4.1 support 2018-03-17 23:53:24 +09:00
John Rommel Estropia
2dd033c002 Merge branch 'develop' into prototype/Swift_4_1 2018-03-10 21:09:29 +09:00
John Rommel Estropia
c7fcba112e Fix bug where ListMonitor sectionIndexTitles are not updated on refetch (fixes #218) 2018-03-10 21:09:18 +09:00
John Rommel Estropia
c8b1c4358f Fix bug where ListMonitor sectionIndexTitles are not updated on refetch (fixes #218) 2018-03-10 21:08:40 +09:00
John Rommel Estropia
5431e2e974 Swift 4.1 support 2018-03-10 21:07:53 +09:00
John Rommel Estropia
83e6082c56 Merge branch 'develop' of github.com:JohnEstropia/CoreStore into develop 2018-01-07 23:25:11 +09:00
John Rommel Estropia
c7bdbbde57 convert value to native type before formatting predicates 2018-01-07 21:06:35 +09:00
John Estropia
abf15c8aa8 Merge pull request #232 from kf99916/external-storage-migration
External storage migration
2018-01-06 17:48:38 +09:00
Zheng-Xiang Ke
d9db7e4a82 Typo 2018-01-06 15:00:53 +08:00
John Estropia
65dbc22ddd Merge pull request #231 from doodzik/patch-1
Fix syntax error in readme
2018-01-06 15:11:48 +09:00
Zheng-Xiang Ke
51961dd737 Migrate external storage 2018-01-06 10:22:44 +08:00
Frederik Dudzik
18a7055cdf Fix syntax error 2018-01-05 21:16:04 +01:00
42 changed files with 330 additions and 207 deletions

View File

@@ -1 +0,0 @@
4.0

View File

@@ -14,10 +14,6 @@ env:
- DESTINATION="OS=10.3,name=iPhone 7" SCHEME="CoreStore iOS" SDK=iphonesimulator11.0 RUN_TESTS="YES" POD_LINT="NO"
- DESTINATION="OS=10.1,name=iPhone 7" SCHEME="CoreStore iOS" SDK=iphonesimulator11.0 RUN_TESTS="YES" POD_LINT="NO"
- DESTINATION="OS=9.0,name=iPhone 6 Plus" SCHEME="CoreStore iOS" SDK=iphonesimulator11.0 RUN_TESTS="YES" POD_LINT="NO"
- DESTINATION="OS=8.4,name=iPhone 6" SCHEME="CoreStore iOS" SDK=iphonesimulator11.0 RUN_TESTS="YES" POD_LINT="NO"
- DESTINATION="OS=8.3,name=iPhone 5S" SCHEME="CoreStore iOS" SDK=iphonesimulator11.0 RUN_TESTS="YES" POD_LINT="NO"
- DESTINATION="OS=8.3,name=iPhone 5" SCHEME="CoreStore iOS" SDK=iphonesimulator11.0 RUN_TESTS="YES" POD_LINT="NO"
- DESTINATION="OS=8.3,name=iPhone 4S" SCHEME="CoreStore iOS" SDK=iphonesimulator11.0 RUN_TESTS="YES" POD_LINT="NO"
- DESTINATION="arch=x86_64" SCHEME="CoreStore OSX" SDK=macosx10.13 RUN_TESTS="YES" POD_LINT="NO"
- DESTINATION="OS=4.0,name=Apple Watch - 42mm" SCHEME="CoreStore watchOS" SDK=watchsimulator4.0 RUN_TESTS="NO" POD_LINT="NO"
- DESTINATION="OS=3.2,name=Apple Watch - 42mm" SCHEME="CoreStore watchOS" SDK=watchsimulator4.0 RUN_TESTS="NO" POD_LINT="NO"

View File

@@ -1,14 +1,15 @@
Pod::Spec.new do |s|
s.name = "CoreStore"
s.version = "5.0.0"
s.version = "5.2.0"
s.swift_version = "4.1"
s.license = "MIT"
s.summary = "Unleashing the real power of Core Data with the elegance and safety of Swift"
s.homepage = "https://github.com/JohnEstropia/CoreStore"
s.author = { "John Rommel Estropia" => "rommel.estropia@gmail.com" }
s.source = { :git => "https://github.com/JohnEstropia/CoreStore.git", :tag => s.version.to_s }
s.ios.deployment_target = "8.0"
s.osx.deployment_target = "10.10"
s.ios.deployment_target = "9.0"
s.osx.deployment_target = "10.11"
s.watchos.deployment_target = "2.0"
s.tvos.deployment_target = "9.0"

View File

@@ -1754,7 +1754,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0900;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = "John Rommel Estropia";
TargetAttributes = {
2F03A52F19C5C6DA005002A5 = {
@@ -2648,6 +2648,7 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
@@ -2655,6 +2656,7 @@
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -2683,8 +2685,8 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = Sources/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MACOSX_DEPLOYMENT_TARGET = 10.10;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_SWIFT_FLAGS = "-D DEBUG";
@@ -2715,6 +2717,7 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
@@ -2722,6 +2725,7 @@
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -2745,8 +2749,8 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = Sources/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MACOSX_DEPLOYMENT_TARGET = 10.10;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = com.johnestropia.CoreStore;
PRODUCT_NAME = CoreStore;
@@ -2773,6 +2777,7 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
@@ -2792,6 +2797,7 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
@@ -2936,6 +2942,7 @@
GCC_NO_COMMON_BLOCKS = YES;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.11;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -2961,6 +2968,7 @@
GCC_NO_COMMON_BLOCKS = YES;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.11;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-O";

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
@@ -56,7 +55,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -40,7 +40,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
@@ -75,7 +74,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
@@ -91,6 +89,12 @@
ReferencedContainer = "container:CoreStore.xcodeproj">
</BuildableReference>
</MacroExpansion>
<CommandLineArguments>
<CommandLineArgument
argument = "-com.apple.CoreData.SQLDebug 2"
isEnabled = "NO">
</CommandLineArgument>
</CommandLineArguments>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
@@ -56,7 +55,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
@@ -37,7 +36,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@@ -265,7 +265,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0900;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = "John Rommel Estropia";
TargetAttributes = {
B54AAD481AF4D26E00848AE0 = {
@@ -375,12 +375,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -408,7 +410,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -430,12 +432,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -456,7 +460,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
@@ -470,7 +474,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = CoreStoreDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.johnestropia.corestore.demo;
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -484,7 +488,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = CoreStoreDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.johnestropia.corestore.demo;
PRODUCT_NAME = "$(TARGET_NAME)";

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
@@ -46,7 +45,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"

View File

@@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>4.0.3</string>
<string>5.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>

View File

@@ -268,7 +268,6 @@ class ListObserverDemoViewController: UITableViewController, ListSectionObserver
self.tableView.insertSections(IndexSet(integer: sectionIndex), with: .automatic)
}
func listMonitor(_ monitor: ListMonitor<Palette>, didDeleteSection sectionInfo: NSFetchedResultsSectionInfo, fromSectionIndex sectionIndex: Int) {
self.tableView.deleteSections(IndexSet(integer: sectionIndex), with: .automatic)

View File

@@ -184,15 +184,15 @@ class ObjectObserverDemoViewController: UIViewController, ObjectObserver {
self.hsbLabel?.text = palette.colorText
if changedKeys == nil || changedKeys?.contains(Palette.keyPath{ $0.hue }) == true {
if changedKeys == nil || changedKeys?.contains(String(keyPath: \Palette.hue)) == true {
self.hueSlider?.value = Float(palette.hue.value)
}
if changedKeys == nil || changedKeys?.contains(Palette.keyPath{ $0.saturation }) == true {
if changedKeys == nil || changedKeys?.contains(String(keyPath: \Palette.saturation)) == true {
self.saturationSlider?.value = palette.saturation.value
}
if changedKeys == nil || changedKeys?.contains(Palette.keyPath{ $0.brightness }) == true {
if changedKeys == nil || changedKeys?.contains(String(keyPath: \Palette.brightness)) == true {
self.brightnessSlider?.value = palette.brightness.value
}

View File

@@ -7,6 +7,7 @@
//
import UIKit
import Contacts
import CoreLocation
import MapKit
import AddressBookUI
@@ -203,11 +204,23 @@ class TransactionsDemoViewController: UIViewController, MKMapViewDelegate, Objec
CLLocation(latitude: place.latitude, longitude: place.longitude),
completionHandler: { [weak self] (placemarks, error) -> Void in
if let placemark = placemarks?.first, let addressDictionary = placemark.addressDictionary {
if let placemark = placemarks?.first, let dictionary = placemark.addressDictionary {
let place = transaction.edit(Static.placeController.object)
place?.title = placemark.name
place?.subtitle = ABCreateStringWithAddressDictionary(addressDictionary, true)
place?.subtitle = CNPostalAddressFormatter.string(
from: autoreleasepool {
let address = CNMutablePostalAddress()
(dictionary["Street"] as? String).flatMap({ address.street = $0 })
(dictionary["State"] as? String).flatMap({ address.state = $0 })
(dictionary["City"] as? String).flatMap({ address.city = $0 })
(dictionary["Country"] as? String).flatMap({ address.country = $0 })
(dictionary["ZIP"] as? String).flatMap({ address.postalCode = $0 })
return address
},
style: .mailingAddress
)
transaction.commit { (_) -> Void in }
}

View File

@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>5.2.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>

View File

@@ -18,10 +18,10 @@ Unleashing the real power of Core Data with the elegance and safety of Swift
<br />
</p>
* **Swift 4.0:** iOS 8+ / macOS 10.10+ / watchOS 2.0+ / tvOS 9.0+
* **Swift 4.1:** iOS 9+ / macOS 10.10+ / watchOS 2.0+ / tvOS 9.0+
* Other Swift versions: [Swift 3.2(version 4.2.3)](https://github.com/JohnEstropia/CoreStore/tree/4.2.3)
Upgrading from CoreStore 4.2 (Swift 3.2) to 5.0 (Swift 4.0)? Check out the [new features](#features) and make sure to read the [Change logs](https://github.com/JohnEstropia/CoreStore/releases).
Upgrading from CoreStore 4.2 (Swift 3.2) to 5.x (Swift 4.x)? Check out the [new features](#features) and make sure to read the [Change logs](https://github.com/JohnEstropia/CoreStore/releases).
CoreStore is now part of the [Swift Source Compatibility projects](https://swift.org/source-compatibility/#current-list-of-projects).
@@ -215,9 +215,9 @@ let migrationProgress = dataStack.addStorage(
completion: { (result) -> Void in
switch result {
case .success(let storage):
print("Successfully added sqlite store: \(storage)"
print("Successfully added sqlite store: \(storage)")
case .failure(let error):
print("Failed adding sqlite store with error: \(error)"
print("Failed adding sqlite store with error: \(error)")
}
}
)

View File

@@ -172,7 +172,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction {
"Attempted to delete an entities from an already committed \(cs_typeName(self))."
)
super.delete(([object1, object2] + objects).flatMap { $0 })
super.delete(([object1, object2] + objects).compactMap { $0 })
}
/**

View File

@@ -35,13 +35,13 @@ internal protocol AttributeProtocol: class {
var keyPath: KeyPathString { get }
var isOptional: Bool { get }
var isIndexed: Bool { get }
var isTransient: Bool { get }
var allowsExternalBinaryDataStorage: Bool { get }
var versionHashModifier: () -> String? { get }
var renamingIdentifier: () -> String? { get }
var defaultValue: () -> Any? { get }
var affectedByKeyPaths: () -> Set<String> { get }
weak var parentObject: CoreStoreObject? { get set }
var parentObject: CoreStoreObject? { get set }
var getter: CoreStoreManagedObject.CustomGetter? { get }
var setter: CoreStoreManagedObject.CustomSetter? { get }
}

View File

@@ -108,7 +108,7 @@ public extension BaseDataTransaction {
return try autoreleasepool {
return try sourceArray.flatMap { (source) -> D? in
return try sourceArray.compactMap { (source) -> D? in
let entityType = into.entityClass
guard entityType.shouldInsert(from: source, in: self) else {
@@ -201,7 +201,7 @@ public extension BaseDataTransaction {
var importSourceByID = Dictionary<D.UniqueIDType, D.ImportSource>()
let sortedIDs = try autoreleasepool {
return try sourceArray.flatMap { (source) -> D.UniqueIDType? in
return try sourceArray.compactMap { (source) -> D.UniqueIDType? in
guard let uniqueIDValue = try entityType.uniqueID(from: source, in: self) else {

View File

@@ -181,7 +181,7 @@ public /*abstract*/ class BaseDataTransaction {
*/
public func delete<D: DynamicObject>(_ object1: D?, _ object2: D?, _ objects: D?...) {
self.delete(([object1, object2] + objects).flatMap { $0 })
self.delete(([object1, object2] + objects).compactMap { $0 })
}
/**
@@ -230,7 +230,7 @@ public /*abstract*/ class BaseDataTransaction {
!self.isCommitted,
"Attempted to access inserted objects from an already committed \(cs_typeName(self))."
)
return Set(self.context.insertedObjects.flatMap({ entity.cs_matches(object: $0) ? entity.cs_fromRaw(object: $0) : nil }))
return Set(self.context.insertedObjects.compactMap({ entity.cs_matches(object: $0) ? entity.cs_fromRaw(object: $0) : nil }))
}
/**
@@ -267,7 +267,7 @@ public /*abstract*/ class BaseDataTransaction {
!self.isCommitted,
"Attempted to access inserted objects IDs from an already committed \(cs_typeName(self))."
)
return Set(self.context.insertedObjects.flatMap({ entity.cs_matches(object: $0) ? $0.objectID : nil }))
return Set(self.context.insertedObjects.compactMap({ entity.cs_matches(object: $0) ? $0.objectID : nil }))
}
/**
@@ -286,7 +286,7 @@ public /*abstract*/ class BaseDataTransaction {
!self.isCommitted,
"Attempted to access updated objects from an already committed \(cs_typeName(self))."
)
return Set(self.context.updatedObjects.flatMap({ entity.cs_matches(object: $0) ? entity.cs_fromRaw(object: $0) : nil }))
return Set(self.context.updatedObjects.compactMap({ entity.cs_matches(object: $0) ? entity.cs_fromRaw(object: $0) : nil }))
}
/**
@@ -323,7 +323,7 @@ public /*abstract*/ class BaseDataTransaction {
!self.isCommitted,
"Attempted to access updated object IDs from an already committed \(cs_typeName(self))."
)
return Set(self.context.updatedObjects.flatMap({ entity.cs_matches(object: $0) ? $0.objectID : nil }))
return Set(self.context.updatedObjects.compactMap({ entity.cs_matches(object: $0) ? $0.objectID : nil }))
}
/**
@@ -342,7 +342,7 @@ public /*abstract*/ class BaseDataTransaction {
!self.isCommitted,
"Attempted to access deleted objects from an already committed \(cs_typeName(self))."
)
return Set(self.context.deletedObjects.flatMap({ entity.cs_matches(object: $0) ? entity.cs_fromRaw(object: $0) : nil }))
return Set(self.context.deletedObjects.compactMap({ entity.cs_matches(object: $0) ? entity.cs_fromRaw(object: $0) : nil }))
}
/**
@@ -380,7 +380,7 @@ public /*abstract*/ class BaseDataTransaction {
!self.isCommitted,
"Attempted to access deleted object IDs from an already committed \(cs_typeName(self))."
)
return Set(self.context.deletedObjects.flatMap({ entity.cs_matches(object: $0) ? $0.objectID : nil }))
return Set(self.context.deletedObjects.compactMap({ entity.cs_matches(object: $0) ? $0.objectID : nil }))
}

View File

@@ -1177,7 +1177,6 @@ extension NSAttributeDescription: CoreStoreDebugStringConvertible {
("isOptional", self.isOptional),
("isTransient", self.isTransient),
("userInfo", self.userInfo as Any),
("isIndexed", self.isIndexed),
("versionHash", self.versionHash),
("versionHashModifier", self.versionHashModifier as Any),
("isIndexedBySpotlight", self.isIndexedBySpotlight),
@@ -1248,13 +1247,17 @@ extension NSEntityDescription: CoreStoreDebugStringConvertible {
("userInfo", self.userInfo as Any),
("versionHash", self.versionHash),
("versionHashModifier", self.versionHashModifier as Any),
("renamingIdentifier", self.renamingIdentifier as Any),
("compoundIndexes", self.compoundIndexes)
("renamingIdentifier", self.renamingIdentifier as Any)
]
if #available(iOS 9.0, OSXApplicationExtension 10.11, OSX 10.11, *) {
if #available(iOS 11.0, OSX 10.13, watchOS 4.0, tvOS 11.0, *) {
info.append(("uniquenessConstraints", self.uniquenessConstraints))
info.append(("indexes", self.indexes))
}
else {
info.append(("compoundIndexes", self.compoundIndexes))
}
info.append(("uniquenessConstraints", self.uniquenessConstraints))
return createFormattedString(
"(", ")",
info

View File

@@ -282,7 +282,7 @@ public enum CoreStoreErrorCode: Int {
// MARK: - NSError
public extension NSError {
internal extension NSError {
// MARK: Internal

View File

@@ -61,7 +61,7 @@ public extension ValueContainer.Required {
*/
public static func < (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where<O> {
return Where("%K < %@", attribute.keyPath, value)
return Where("%K < %@", attribute.keyPath, value.cs_toQueryableNativeType())
}
/**
@@ -72,7 +72,7 @@ public extension ValueContainer.Required {
*/
public static func > (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where<O> {
return Where("%K > %@", attribute.keyPath, value)
return Where("%K > %@", attribute.keyPath, value.cs_toQueryableNativeType())
}
/**
@@ -83,7 +83,7 @@ public extension ValueContainer.Required {
*/
public static func <= (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where<O> {
return Where("%K <= %@", attribute.keyPath, value)
return Where("%K <= %@", attribute.keyPath, value.cs_toQueryableNativeType())
}
/**
@@ -94,7 +94,7 @@ public extension ValueContainer.Required {
*/
public static func >= (_ attribute: ValueContainer<O>.Required<V>, _ value: V) -> Where<O> {
return Where("%K >= %@", attribute.keyPath, value)
return Where("%K >= %@", attribute.keyPath, value.cs_toQueryableNativeType())
}
/**
@@ -146,7 +146,7 @@ public extension ValueContainer.Optional {
if let value = value {
return Where("%K < %@", attribute.keyPath, value)
return Where("%K < %@", attribute.keyPath, value.cs_toQueryableNativeType())
}
else {
@@ -164,7 +164,7 @@ public extension ValueContainer.Optional {
if let value = value {
return Where("%K > %@", attribute.keyPath, value)
return Where("%K > %@", attribute.keyPath, value.cs_toQueryableNativeType())
}
else {
@@ -182,7 +182,7 @@ public extension ValueContainer.Optional {
if let value = value {
return Where("%K <= %@", attribute.keyPath, value)
return Where("%K <= %@", attribute.keyPath, value.cs_toQueryableNativeType())
}
else {
@@ -200,7 +200,7 @@ public extension ValueContainer.Optional {
if let value = value {
return Where("%K >= %@", attribute.keyPath, value)
return Where("%K >= %@", attribute.keyPath, value.cs_toQueryableNativeType())
}
else {

View File

@@ -219,7 +219,7 @@ public final class CoreStoreSchema: DynamicSchema {
allCustomGettersSetters[entity] = customGetterSetterByKeyPaths
}
CoreStoreSchema.secondPassConnectRelationshipAttributes(for: entityDescriptionsByEntity)
CoreStoreSchema.thirdPassConnectInheritanceTree(for: entityDescriptionsByEntity)
CoreStoreSchema.thirdPassConnectInheritanceTreeAndIndexes(for: entityDescriptionsByEntity)
CoreStoreSchema.fourthPassSynthesizeManagedObjectClasses(
for: entityDescriptionsByEntity,
allCustomGettersSetters: allCustomGettersSetters
@@ -292,9 +292,9 @@ public final class CoreStoreSchema: DynamicSchema {
description.name = attribute.keyPath
description.attributeType = Swift.type(of: attribute).attributeType
description.isOptional = attribute.isOptional
description.isIndexed = attribute.isIndexed
description.defaultValue = attribute.defaultValue()
description.isTransient = attribute.isTransient
description.allowsExternalBinaryDataStorage = attribute.allowsExternalBinaryDataStorage
description.versionHashModifier = attribute.versionHashModifier()
description.renamingIdentifier = attribute.renamingIdentifier()
propertyDescriptions.append(description)
@@ -415,7 +415,7 @@ public final class CoreStoreSchema: DynamicSchema {
}
}
private static func thirdPassConnectInheritanceTree(for entityDescriptionsByEntity: [DynamicEntity: NSEntityDescription]) {
private static func thirdPassConnectInheritanceTreeAndIndexes(for entityDescriptionsByEntity: [DynamicEntity: NSEntityDescription]) {
func connectBaseEntity(mirror: Mirror, entityDescription: NSEntityDescription) {
@@ -441,6 +441,53 @@ public final class CoreStoreSchema: DynamicSchema {
entityDescription: entityDescription
)
}
for (entity, entityDescription) in entityDescriptionsByEntity {
let uniqueConstraints = entity.uniqueConstraints.filter({ !$0.isEmpty })
if !uniqueConstraints.isEmpty {
CoreStore.assert(
entityDescription.superentity == nil,
"Uniqueness constraints must be defined at the highest level possible."
)
entityDescription.uniquenessConstraints = entity.uniqueConstraints.map { $0.map { $0 as NSString } }
}
guard !entity.indexes.isEmpty else {
continue
}
defer {
entityDescription.coreStoreEntity = entity // reserialize
}
let attributesByName = entityDescription.attributesByName
if #available(iOS 11.0, OSX 10.13, watchOS 4.0, tvOS 11.0, *) {
entityDescription.indexes = entity.indexes.map { (compoundIndexes) in
return NSFetchIndexDescription.init(
name: "_CoreStoreSchema_indexes_\(entityDescription.name!)_\(compoundIndexes.joined(separator: "-"))",
elements: compoundIndexes.map { (keyPath) in
return NSFetchIndexElementDescription(
property: attributesByName[keyPath]!,
collationType: .binary
)
}
)
}
}
else {
entityDescription.compoundIndexes = entity.indexes.map { (compoundIndexes) in
return compoundIndexes.map { (keyPath) in
return attributesByName[keyPath]!
}
}
}
}
}
private static func fourthPassSynthesizeManagedObjectClasses(for entityDescriptionsByEntity: [DynamicEntity: NSEntityDescription], allCustomGettersSetters: [DynamicEntity: [KeyPathString: CoreStoreManagedObject.CustomGetterSetter]]) {

View File

@@ -56,8 +56,8 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
CoreStore.assert(
cs_lazy {
let sources = entityMappings.flatMap({ $0.entityMappingSourceEntity })
let destinations = entityMappings.flatMap({ $0.entityMappingDestinationEntity })
let sources = entityMappings.compactMap({ $0.entityMappingSourceEntity })
let destinations = entityMappings.compactMap({ $0.entityMappingDestinationEntity })
return sources.count == Set(sources).count
&& destinations.count == Set(destinations).count
},

View File

@@ -708,9 +708,9 @@ public extension DataStack {
var fakeProgress: Float = 0
var recursiveCheck: () -> Void = {}
recursiveCheck = {
recursiveCheck = { [weak timerQueue] in
guard fakeProgress < 1 else {
guard let timerQueue = timerQueue, fakeProgress < 1 else {
return
}
@@ -739,13 +739,13 @@ public extension DataStack {
fakeProgress = 1
}
try storage.cs_finalizeStorageAndWait(soureModelHint: destinationModel)
_ = try? storage.cs_finalizeStorageAndWait(soureModelHint: destinationModel)
progress.completedUnitCount = progress.totalUnitCount
return
}
catch {
throw CoreStoreError(error)
// Lightweight migration failed somehow. Proceed using InferedMappingModel below
}
}
@@ -760,6 +760,11 @@ public extension DataStack {
attributes: nil
)
let externalStorageFolderName = ".\(fileURL.deletingPathExtension().lastPathComponent)_SUPPORT"
let temporaryExternalStorageURL = temporaryDirectoryURL.appendingPathComponent(
externalStorageFolderName,
isDirectory: true
)
let temporaryFileURL = temporaryDirectoryURL.appendingPathComponent(
fileURL.lastPathComponent,
isDirectory: false
@@ -799,18 +804,32 @@ public extension DataStack {
do {
try fileManager.replaceItem(
at: fileURL as URL,
at: fileURL,
withItemAt: temporaryFileURL,
backupItemName: nil,
options: [],
resultingItemURL: nil
)
if fileManager.fileExists(atPath: temporaryExternalStorageURL.path) {
let externalStorageURL = fileURL
.deletingLastPathComponent()
.appendingPathComponent(externalStorageFolderName, isDirectory: true)
try fileManager.replaceItem(
at: externalStorageURL,
withItemAt: temporaryExternalStorageURL,
backupItemName: nil,
options: [],
resultingItemURL: nil
)
}
progress.completedUnitCount = progress.totalUnitCount
}
catch {
_ = try? fileManager.removeItem(at: temporaryFileURL)
_ = try? fileManager.removeItem(at: temporaryExternalStorageURL)
throw CoreStoreError(error)
}
}

View File

@@ -26,12 +26,23 @@
import Foundation
// MARK: - AnyDynamicKeyPath
public protocol AnyDynamicKeyPath {
/**
The keyPath string
*/
var cs_keyPathString: String { get }
}
// MARK: - DynamicKeyPath
/**
Used only for utility methods.
*/
public protocol DynamicKeyPath {
public protocol DynamicKeyPath: AnyDynamicKeyPath {
/**
The DynamicObject type
@@ -42,11 +53,6 @@ public protocol DynamicKeyPath {
The Value type
*/
associatedtype ValueType
/**
The keyPath string
*/
var cs_keyPathString: String { get }
}

View File

@@ -181,7 +181,6 @@ public extension DynamicSchema {
default:
fatalError("Unsupported attribute type: \(attribute.attributeType.rawValue)")
}
let indexedString = attribute.isIndexed ? ", isIndexed: true" : ""
let transientString = attribute.isTransient ? ", isTransient: true" : ""
// TODO: escape strings
let versionHashModifierString = attribute.versionHashModifier
@@ -189,7 +188,7 @@ public extension DynamicSchema {
// TODO: escape strings
let renamingIdentifierString = attribute.renamingIdentifier
.flatMap({ ($0 == attributeName ? "" : ", renamingIdentifier: \"\($0)\"") as String }) ?? ""
output.append(" let \(attributeName) = \(containerType)<\(String(describing: valueType))>(\"\(attributeName)\"\(indexedString)\(defaultString)\(transientString)\(versionHashModifierString)\(renamingIdentifierString))\n")
output.append(" let \(attributeName) = \(containerType)<\(String(describing: valueType))>(\"\(attributeName)\"\(defaultString)\(transientString)\(versionHashModifierString)\(renamingIdentifierString))\n")
}
}

View File

@@ -57,7 +57,7 @@ import ObjectiveC
- SeeAlso: CoreStoreSchema
- SeeAlso: CoreStoreObject
*/
public final class Entity<O: DynamicObject>: DynamicEntity {
public final class Entity<O: CoreStoreObject>: DynamicEntity {
/**
Initializes an `Entity`. Always provide a concrete generic type to `Entity`.
@@ -66,11 +66,20 @@ public final class Entity<O: DynamicObject>: DynamicEntity {
```
- parameter entityName: the `NSEntityDescription` name to use for the entity
- parameter isAbstract: set to `true` if the entity is meant to be an abstract class and can only be initialized with subclass types.
- parameter versionHashModifier: The version hash modifier for the entity. Used to mark or denote an entity as being a different "version" than another even if all of the values which affect persistence are equal. (Such a difference is important in cases where, for example, the structure of an entity is unchanged but the format or content of data has changed.)
- parameter versionHashModifier: the version hash modifier for the entity. Used to mark or denote an entity as being a different "version" than another even if all of the values which affect persistence are equal. (Such a difference is important in cases where, for example, the structure of an entity is unchanged but the format or content of data has changed.)
- parameter indexes: the compound indexes for the entity as an array of arrays. The arrays contained in the returned array contain `KeyPath`s to properties of the entity.
- parameter uniqueConstraints: sets uniqueness constraints for the entity. A uniqueness constraint is a set of one or more `KeyPath`s whose value must be unique over the set of instances of that entity. This value forms part of the entity's version hash. Uniqueness constraint violations can be computationally expensive to handle. It is highly suggested that there be only one uniqueness constraint per entity hierarchy. Uniqueness constraints must be defined at the highest level possible, and CoreStore will raise an assertion failure if unique constraints are added to a sub entity.
*/
public convenience init(_ entityName: String, isAbstract: Bool = false, versionHashModifier: String? = nil) {
public convenience init(_ entityName: String, isAbstract: Bool = false, versionHashModifier: String? = nil, indexes: [[PartialKeyPath<O>]] = [], uniqueConstraints: [[PartialKeyPath<O>]] = []) {
self.init(O.self, entityName, isAbstract: isAbstract, versionHashModifier: versionHashModifier)
self.init(
O.self,
entityName,
isAbstract: isAbstract,
versionHashModifier: versionHashModifier,
indexes: indexes,
uniqueConstraints: uniqueConstraints
)
}
/**
@@ -81,11 +90,28 @@ public final class Entity<O: DynamicObject>: DynamicEntity {
- parameter type: the `DynamicObject` type associated with the entity
- parameter entityName: the `NSEntityDescription` name to use for the entity
- parameter isAbstract: set to `true` if the entity is meant to be an abstract class and can only be initialized with subclass types.
- parameter versionHashModifier: The version hash modifier for the entity. Used to mark or denote an entity as being a different "version" than another even if all of the values which affect persistence are equal. (Such a difference is important in cases where, for example, the structure of an entity is unchanged but the format or content of data has changed.)
- parameter versionHashModifier: the version hash modifier for the entity. Used to mark or denote an entity as being a different "version" than another even if all of the values which affect persistence are equal. (Such a difference is important in cases where, for example, the structure of an entity is unchanged but the format or content of data has changed.)
- parameter indexes: the compound indexes for the entity as an array of arrays. The arrays contained in the returned array contain KeyPath's to properties of the entity.
- parameter uniqueConstraints: sets uniqueness constraints for the entity. A uniqueness constraint is a set of one or more `KeyPath`s whose value must be unique over the set of instances of that entity. This value forms part of the entity's version hash. Uniqueness constraint violations can be computationally expensive to handle. It is highly suggested that there be only one uniqueness constraint per entity hierarchy. Uniqueness constraints must be defined at the highest level possible, and CoreStore will raise an assertion failure if unique constraints are added to a sub entity.
*/
public init(_ type: O.Type, _ entityName: String, isAbstract: Bool = false, versionHashModifier: String? = nil) {
public init(_ type: O.Type, _ entityName: String, isAbstract: Bool = false, versionHashModifier: String? = nil, indexes: [[PartialKeyPath<O>]] = [], uniqueConstraints: [[PartialKeyPath<O>]] = []) {
super.init(type: type, entityName: entityName, isAbstract: isAbstract, versionHashModifier: versionHashModifier)
let meta = O.meta
let toStringArray: ([PartialKeyPath<O>]) -> [KeyPathString] = {
return $0.map {
return (meta[keyPath: $0] as! AnyDynamicKeyPath).cs_keyPathString
}
}
super.init(
type: type,
entityName: entityName,
isAbstract: isAbstract,
versionHashModifier: versionHashModifier,
indexes: indexes.map(toStringArray),
uniqueConstraints: uniqueConstraints.map(toStringArray)
)
}
}
@@ -117,6 +143,16 @@ public /*abstract*/ class DynamicEntity: Hashable {
*/
public let versionHashModifier: String?
/**
Do not use directly.
*/
public let indexes: [[KeyPathString]]
/**
Do not use directly.
*/
public let uniqueConstraints: [[KeyPathString]]
// MARK: Equatable
@@ -126,6 +162,8 @@ public /*abstract*/ class DynamicEntity: Hashable {
&& lhs.entityName == rhs.entityName
&& lhs.isAbstract == rhs.isAbstract
&& lhs.versionHashModifier == rhs.versionHashModifier
&& lhs.indexes == rhs.indexes
&& lhs.uniqueConstraints == rhs.uniqueConstraints
}
// MARK: Hashable
@@ -136,16 +174,20 @@ public /*abstract*/ class DynamicEntity: Hashable {
^ self.entityName.hashValue
^ self.isAbstract.hashValue
^ (self.versionHashModifier ?? "").hashValue
// ^ self.indexes.hashValue
// ^ self.uniqueConstraints.hashValue
}
// MARK: Internal
internal init(type: DynamicObject.Type, entityName: String, isAbstract: Bool = false, versionHashModifier: String?) {
internal init(type: DynamicObject.Type, entityName: String, isAbstract: Bool, versionHashModifier: String?, indexes: [[KeyPathString]], uniqueConstraints: [[KeyPathString]]) {
self.type = type
self.entityName = entityName
self.isAbstract = isAbstract
self.versionHashModifier = versionHashModifier
self.indexes = indexes
self.uniqueConstraints = uniqueConstraints
}
}

View File

@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.0.0</string>
<string>5.2.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>

View File

@@ -109,7 +109,7 @@ public func ~= <O: NSManagedObject, V: QueryableAttributeType & Equatable, S: Se
*/
public func < <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, V>, _ value: V) -> Where<O> {
return Where<O>("%K < %@", keyPath._kvcKeyPathString!, value)
return Where<O>("%K < %@", keyPath._kvcKeyPathString!, value.cs_toQueryableNativeType())
}
/**
@@ -120,7 +120,7 @@ public func < <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ key
*/
public func > <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, V>, _ value: V) -> Where<O> {
return Where<O>("%K > %@", keyPath._kvcKeyPathString!, value)
return Where<O>("%K > %@", keyPath._kvcKeyPathString!, value.cs_toQueryableNativeType())
}
/**
@@ -131,7 +131,7 @@ public func > <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ key
*/
public func <= <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, V>, _ value: V) -> Where<O> {
return Where<O>("%K <= %@", keyPath._kvcKeyPathString!, value)
return Where<O>("%K <= %@", keyPath._kvcKeyPathString!, value.cs_toQueryableNativeType())
}
/**
@@ -142,7 +142,7 @@ public func <= <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ ke
*/
public func >= <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ keyPath: KeyPath<O, V>, _ value: V) -> Where<O> {
return Where<O>("%K >= %@", keyPath._kvcKeyPathString!, value)
return Where<O>("%K >= %@", keyPath._kvcKeyPathString!, value.cs_toQueryableNativeType())
}
@@ -158,7 +158,7 @@ public func < <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ key
if let value = value {
return Where<O>("%K < %@", keyPath._kvcKeyPathString!, value)
return Where<O>("%K < %@", keyPath._kvcKeyPathString!, value.cs_toQueryableNativeType())
}
else {
@@ -176,7 +176,7 @@ public func > <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ key
if let value = value {
return Where<O>("%K > %@", keyPath._kvcKeyPathString!, value)
return Where<O>("%K > %@", keyPath._kvcKeyPathString!, value.cs_toQueryableNativeType())
}
else {
@@ -194,7 +194,7 @@ public func <= <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ ke
if let value = value {
return Where<O>("%K <= %@", keyPath._kvcKeyPathString!, value)
return Where<O>("%K <= %@", keyPath._kvcKeyPathString!, value.cs_toQueryableNativeType())
}
else {
@@ -212,7 +212,7 @@ public func >= <O: NSManagedObject, V: QueryableAttributeType & Comparable>(_ ke
if let value = value {
return Where<O>("%K >= %@", keyPath._kvcKeyPathString!, value)
return Where<O>("%K >= %@", keyPath._kvcKeyPathString!, value.cs_toQueryableNativeType())
}
else {
@@ -441,7 +441,7 @@ public func ~= <O, V, S: Sequence>(_ sequence: S, _ keyPath: KeyPath<O, ValueCon
*/
public func < <O, V: Comparable>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, _ value: V) -> Where<O> {
return Where<O>("%K < %@", O.meta[keyPath: keyPath].keyPath, value)
return Where<O>("%K < %@", O.meta[keyPath: keyPath].keyPath, value.cs_toQueryableNativeType())
}
/**
@@ -452,7 +452,7 @@ public func < <O, V: Comparable>(_ keyPath: KeyPath<O, ValueContainer<O>.Require
*/
public func > <O, V: Comparable>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, _ value: V) -> Where<O> {
return Where<O>("%K > %@", O.meta[keyPath: keyPath].keyPath, value)
return Where<O>("%K > %@", O.meta[keyPath: keyPath].keyPath, value.cs_toQueryableNativeType())
}
/**
@@ -463,7 +463,7 @@ public func > <O, V: Comparable>(_ keyPath: KeyPath<O, ValueContainer<O>.Require
*/
public func <= <O, V: Comparable>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, _ value: V) -> Where<O> {
return Where<O>("%K <= %@", O.meta[keyPath: keyPath].keyPath, value)
return Where<O>("%K <= %@", O.meta[keyPath: keyPath].keyPath, value.cs_toQueryableNativeType())
}
/**
@@ -474,7 +474,7 @@ public func <= <O, V: Comparable>(_ keyPath: KeyPath<O, ValueContainer<O>.Requir
*/
public func >= <O, V: Comparable>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, _ value: V) -> Where<O> {
return Where<O>("%K >= %@", O.meta[keyPath: keyPath].keyPath, value)
return Where<O>("%K >= %@", O.meta[keyPath: keyPath].keyPath, value.cs_toQueryableNativeType())
}
@@ -490,7 +490,7 @@ public func < <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ val
if let value = value {
return Where<O>("%K < %@", O.meta[keyPath: keyPath].keyPath, value)
return Where<O>("%K < %@", O.meta[keyPath: keyPath].keyPath, value.cs_toQueryableNativeType())
}
else {
@@ -508,7 +508,7 @@ public func > <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ val
if let value = value {
return Where<O>("%K > %@", O.meta[keyPath: keyPath].keyPath, value)
return Where<O>("%K > %@", O.meta[keyPath: keyPath].keyPath, value.cs_toQueryableNativeType())
}
else {
@@ -526,7 +526,7 @@ public func <= <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ va
if let value = value {
return Where<O>("%K <= %@", O.meta[keyPath: keyPath].keyPath, value)
return Where<O>("%K <= %@", O.meta[keyPath: keyPath].keyPath, value.cs_toQueryableNativeType())
}
else {
@@ -544,7 +544,7 @@ public func >= <O, V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, _ va
if let value = value {
return Where<O>("%K >= %@", O.meta[keyPath: keyPath].keyPath, value)
return Where<O>("%K >= %@", O.meta[keyPath: keyPath].keyPath, value.cs_toQueryableNativeType())
}
else {

View File

@@ -952,6 +952,8 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
sectionBy: self.sectionBy,
applyFetchClauses: self.applyFetchClauses
)
newFetchedResultsControllerDelegate.enabled = false
newFetchedResultsControllerDelegate.handler = self
self.transactionQueue.async { [weak self] in
@@ -973,7 +975,7 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
}
(self.fetchedResultsController, self.fetchedResultsControllerDelegate) = (newFetchedResultsController, newFetchedResultsControllerDelegate)
newFetchedResultsControllerDelegate.handler = self
newFetchedResultsControllerDelegate.enabled = true
self.isPendingRefetch = false

View File

@@ -42,7 +42,10 @@ internal final class MigrationManager: NSMigrationManager, ProgressReporting {
return
}
let progress = self.progress
progress.completedUnitCount = Int64(Float(progress.totalUnitCount) * self.migrationProgress)
progress.completedUnitCount = max(
progress.completedUnitCount,
Int64(Float(progress.totalUnitCount) * self.migrationProgress)
)
}

View File

@@ -50,7 +50,9 @@ internal extension NSEntityDescription {
guard let userInfo = self.userInfo,
let typeName = userInfo[UserInfoKey.CoreStoreManagedObjectTypeName] as! String?,
let entityName = userInfo[UserInfoKey.CoreStoreManagedObjectEntityName] as! String?,
let isAbstract = userInfo[UserInfoKey.CoreStoreManagedObjectIsAbstract] as! Bool? else {
let isAbstract = userInfo[UserInfoKey.CoreStoreManagedObjectIsAbstract] as! Bool?,
let indexes = userInfo[UserInfoKey.CoreStoreManagedObjectIndexes] as! [[KeyPathString]]?,
let uniqueConstraints = userInfo[UserInfoKey.CoreStoreManagedObjectUniqueConstraints] as! [[KeyPathString]]? else {
return nil
}
@@ -58,7 +60,9 @@ internal extension NSEntityDescription {
type: NSClassFromString(typeName) as! CoreStoreObject.Type,
entityName: entityName,
isAbstract: isAbstract,
versionHashModifier: userInfo[UserInfoKey.CoreStoreManagedObjectVersionHashModifier] as! String?
versionHashModifier: userInfo[UserInfoKey.CoreStoreManagedObjectVersionHashModifier] as! String?,
indexes: indexes,
uniqueConstraints: uniqueConstraints
)
}
set {
@@ -71,6 +75,8 @@ internal extension NSEntityDescription {
userInfo[UserInfoKey.CoreStoreManagedObjectEntityName] = newValue.entityName
userInfo[UserInfoKey.CoreStoreManagedObjectIsAbstract] = newValue.isAbstract
userInfo[UserInfoKey.CoreStoreManagedObjectVersionHashModifier] = newValue.versionHashModifier
userInfo[UserInfoKey.CoreStoreManagedObjectIndexes] = newValue.indexes
userInfo[UserInfoKey.CoreStoreManagedObjectUniqueConstraints] = newValue.uniqueConstraints
}
}
else {
@@ -81,6 +87,8 @@ internal extension NSEntityDescription {
userInfo[UserInfoKey.CoreStoreManagedObjectEntityName] = nil
userInfo[UserInfoKey.CoreStoreManagedObjectIsAbstract] = nil
userInfo[UserInfoKey.CoreStoreManagedObjectVersionHashModifier] = nil
userInfo[UserInfoKey.CoreStoreManagedObjectIndexes] = nil
userInfo[UserInfoKey.CoreStoreManagedObjectUniqueConstraints] = nil
}
}
}
@@ -139,6 +147,8 @@ internal extension NSEntityDescription {
fileprivate static let CoreStoreManagedObjectEntityName = "CoreStoreManagedObjectEntityName"
fileprivate static let CoreStoreManagedObjectIsAbstract = "CoreStoreManagedObjectIsAbstract"
fileprivate static let CoreStoreManagedObjectVersionHashModifier = "CoreStoreManagedObjectVersionHashModifier"
fileprivate static let CoreStoreManagedObjectIndexes = "CoreStoreManagedObjectIndexes"
fileprivate static let CoreStoreManagedObjectUniqueConstraints = "CoreStoreManagedObjectUniqueConstraints"
fileprivate static let CoreStoreManagedObjectKeyPathsByAffectedKeyPaths = "CoreStoreManagedObjectKeyPathsByAffectedKeyPaths"
fileprivate static let CoreStoreManagedObjectCustomGetterSetterByKeyPaths = "CoreStoreManagedObjectCustomGetterSetterByKeyPaths"

View File

@@ -91,13 +91,13 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
@nonobjc
public func fetchExisting<D: DynamicObject, S: Sequence>(_ objects: S) -> [D] where S.Iterator.Element == D {
return objects.flatMap({ self.fetchExisting($0.cs_id()) })
return objects.compactMap({ self.fetchExisting($0.cs_id()) })
}
@nonobjc
public func fetchExisting<D: DynamicObject, S: Sequence>(_ objectIDs: S) -> [D] where S.Iterator.Element == NSManagedObjectID {
return objectIDs.flatMap({ self.fetchExisting($0) })
return objectIDs.compactMap({ self.fetchExisting($0) })
}
@nonobjc

View File

@@ -1071,7 +1071,7 @@ extension RelationshipContainer.ToManyOrdered {
return relationship.nativeValue.elementsEqual(
collection.lazy.map({ $0.rawObject! }),
by: { ($0 as! NSManagedObject) == ($1 as! NSManagedObject) }
by: { ($0 as! NSManagedObject) == $1 }
)
}
@@ -1089,7 +1089,7 @@ extension RelationshipContainer.ToManyOrdered {
return relationship.nativeValue.elementsEqual(
collection.lazy.map({ $0.rawObject! }),
by: { ($0 as! NSManagedObject) == ($1 as! NSManagedObject) }
by: { ($0 as! NSManagedObject) == $1 }
)
}

View File

@@ -37,7 +37,7 @@ internal protocol RelationshipProtocol: class {
var deleteRule: NSDeleteRule { get }
var inverse: (type: CoreStoreObject.Type, keyPath: () -> KeyPathString?) { get }
var affectedByKeyPaths: () -> Set<String> { get }
weak var parentObject: CoreStoreObject? { get set }
var parentObject: CoreStoreObject? { get set }
var versionHashModifier: () -> String? { get }
var renamingIdentifier: () -> String? { get }
var minCount: Int { get }

View File

@@ -150,7 +150,15 @@ public final class SQLiteStore: LocalStorage {
[NSSQLitePragmasOption: ["journal_mode": "WAL"]]
```
*/
public let storeOptions: [AnyHashable: Any]? = [NSSQLitePragmasOption: ["journal_mode": "WAL"]]
public let storeOptions: [AnyHashable: Any]? = autoreleasepool {
var storeOptions: [AnyHashable: Any] = [NSSQLitePragmasOption: ["journal_mode": "WAL"]]
if #available(iOS 11.0, OSX 10.13, tvOSApplicationExtension 11.0, watchOSApplicationExtension 4.0, *) {
storeOptions[NSBinaryStoreInsecureDecodingCompatibilityOption] = true
}
return storeOptions
}
/**
Do not call directly. Used by the `DataStack` internally.
@@ -212,11 +220,13 @@ public final class SQLiteStore: LocalStorage {
_ = try withExtendedLifetime(NSPersistentStoreCoordinator(managedObjectModel: soureModelHint)) { (coordinator: NSPersistentStoreCoordinator) in
var storeOptions = self.storeOptions ?? [:]
storeOptions[NSSQLitePragmasOption] = ["journal_mode": "DELETE"]
try coordinator.addPersistentStore(
ofType: type(of: self).storeType,
configurationName: self.configuration,
at: fileURL,
options: [NSSQLitePragmasOption: ["journal_mode": "DELETE"]]
options: storeOptions
)
}
_ = try? FileManager.default.removeItem(atPath: "\(self.fileURL.path)-shm")
@@ -276,11 +286,13 @@ public final class SQLiteStore: LocalStorage {
if let soureModel = soureModelHint ?? NSManagedObjectModel.mergedModel(from: nil, forStoreMetadata: metadata) {
let journalUpdatingCoordinator = NSPersistentStoreCoordinator(managedObjectModel: soureModel)
var storeOptions = self.storeOptions ?? [:]
storeOptions[NSSQLitePragmasOption] = ["journal_mode": "DELETE"]
let store = try journalUpdatingCoordinator.addPersistentStore(
ofType: type(of: self).storeType,
configurationName: self.configuration,
at: fileURL,
options: [NSSQLitePragmasOption: ["journal_mode": "DELETE"]]
options: storeOptions
)
try journalUpdatingCoordinator.remove(store)
}

View File

@@ -127,7 +127,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
"Attempted to delete an entities from an already committed \(cs_typeName(self))."
)
super.delete(([object1, object2] + objects).flatMap { $0 })
super.delete(([object1, object2] + objects).compactMap { $0 })
}
/**

View File

@@ -107,8 +107,8 @@ public enum TransformableContainer<O: CoreStoreObject> {
```
- parameter keyPath: the permanent attribute name for this property.
- parameter initial: the initial value for the property when the object is first created. Defaults to the `ImportableAttributeType`'s empty value if not specified.
- parameter isIndexed: `true` if the property should be indexed for searching, otherwise `false`. Defaults to `false` if not specified.
- parameter isTransient: `true` if the property is transient, otherwise `false`. Defaults to `false` if not specified. The transient flag specifies whether or not a property's value is ignored when an object is saved to a persistent store. Transient properties are not saved to the persistent store, but are still managed for undo, redo, validation, and so on.
- parameter allowsExternalBinaryDataStorage: `true` if the attribute allows external binary storage, otherwise `false`.
- parameter versionHashModifier: used to mark or denote a property as being a different "version" than another even if all of the values which affect persistence are equal. (Such a difference is important in cases where the properties are unchanged but the format or content of its data are changed.)
- parameter renamingIdentifier: used to resolve naming conflicts between models. When creating an entity mapping between entities in two managed object models, a source entity property and a destination entity property that share the same identifier indicate that a property mapping should be configured to migrate from the source to the destination. If unset, the identifier will be the property's name.
- parameter customGetter: use this closure as an "override" for the default property getter. The closure receives a `PartialObject<O>`, which acts as a fast, type-safe KVC interface for `CoreStoreObject`. The reason a `CoreStoreObject` instance is not passed directly is because the Core Data runtime is not aware of `CoreStoreObject` properties' static typing, and so loading those info everytime KVO invokes this accessor method incurs a cumulative performance hit (especially in KVO-heavy operations such as `ListMonitor` observing.) When accessing the property value from `PartialObject<O>`, make sure to use `PartialObject<O>.primitiveValue(for:)` instead of `PartialObject<O>.value(for:)`, which would unintentionally execute the same closure again recursively.
@@ -118,8 +118,8 @@ public enum TransformableContainer<O: CoreStoreObject> {
public init(
_ keyPath: KeyPathString,
initial: @autoclosure @escaping () -> V,
isIndexed: Bool = false,
isTransient: Bool = false,
allowsExternalBinaryDataStorage: Bool = false,
versionHashModifier: @autoclosure @escaping () -> String? = nil,
renamingIdentifier: @autoclosure @escaping () -> String? = nil,
customGetter: ((_ partialObject: PartialObject<O>) -> V)? = nil,
@@ -128,8 +128,8 @@ public enum TransformableContainer<O: CoreStoreObject> {
self.keyPath = keyPath
self.defaultValue = initial
self.isIndexed = isIndexed
self.isTransient = isTransient
self.allowsExternalBinaryDataStorage = allowsExternalBinaryDataStorage
self.versionHashModifier = versionHashModifier
self.renamingIdentifier = renamingIdentifier
self.customGetter = customGetter
@@ -199,8 +199,8 @@ public enum TransformableContainer<O: CoreStoreObject> {
internal let keyPath: KeyPathString
internal let isOptional = false
internal let isIndexed: Bool
internal let isTransient: Bool
internal let allowsExternalBinaryDataStorage: Bool
internal let versionHashModifier: () -> String?
internal let renamingIdentifier: () -> String?
internal let defaultValue: () -> Any?
@@ -254,33 +254,24 @@ public enum TransformableContainer<O: CoreStoreObject> {
private let customGetter: ((_ partialObject: PartialObject<O>) -> V)?
private let customSetter: ((_ partialObject: PartialObject<O>, _ newValue: V) -> Void)?
// MARK: Deprecated
@available(*, deprecated: 3.2, renamed: "init(_:initial:isIndexed:isTransient:versionHashModifier:renamingIdentifier:customGetter:customSetter:affectedByKeyPaths:)")
@available(*, unavailable, message: "Indexes are now set through the Entity<T> initializer, which now supports compound indexes.")
public convenience init(
_ keyPath: KeyPathString,
`default`: @autoclosure @escaping () -> V,
isIndexed: Bool = false,
initial: @autoclosure @escaping () -> V,
isIndexed: Bool,
isTransient: Bool = false,
allowsExternalBinaryDataStorage: Bool = false,
versionHashModifier: @autoclosure @escaping () -> String? = nil,
renamingIdentifier: @autoclosure @escaping () -> String? = nil,
customGetter: ((_ partialObject: PartialObject<O>) -> V)? = nil,
customSetter: ((_ partialObject: PartialObject<O>, _ newValue: V) -> Void)? = nil,
affectedByKeyPaths: @autoclosure @escaping () -> Set<String> = []) {
self.init(
keyPath,
initial: `default`,
isIndexed: isIndexed,
isTransient: isTransient,
versionHashModifier: versionHashModifier,
renamingIdentifier: renamingIdentifier,
customGetter: customGetter,
customSetter: customSetter,
affectedByKeyPaths: affectedByKeyPaths
)
fatalError()
}
}
@@ -329,8 +320,8 @@ public enum TransformableContainer<O: CoreStoreObject> {
```
- parameter keyPath: the permanent attribute name for this property.
- parameter initial: the initial value for the property when the object is first created. Defaults to the `ImportableAttributeType`'s empty value if not specified.
- parameter isIndexed: `true` if the property should be indexed for searching, otherwise `false`. Defaults to `false` if not specified.
- parameter isTransient: `true` if the property is transient, otherwise `false`. Defaults to `false` if not specified. The transient flag specifies whether or not a property's value is ignored when an object is saved to a persistent store. Transient properties are not saved to the persistent store, but are still managed for undo, redo, validation, and so on.
- parameter allowsExternalBinaryDataStorage: `true` if the attribute allows external binary storage, otherwise `false`.
- parameter versionHashModifier: used to mark or denote a property as being a different "version" than another even if all of the values which affect persistence are equal. (Such a difference is important in cases where the properties are unchanged but the format or content of its data are changed.)
- parameter renamingIdentifier: used to resolve naming conflicts between models. When creating an entity mapping between entities in two managed object models, a source entity property and a destination entity property that share the same identifier indicate that a property mapping should be configured to migrate from the source to the destination. If unset, the identifier will be the property's name.
- parameter customGetter: use this closure as an "override" for the default property getter. The closure receives a `PartialObject<O>`, which acts as a fast, type-safe KVC interface for `CoreStoreObject`. The reason a `CoreStoreObject` instance is not passed directly is because the Core Data runtime is not aware of `CoreStoreObject` properties' static typing, and so loading those info everytime KVO invokes this accessor method incurs a cumulative performance hit (especially in KVO-heavy operations such as `ListMonitor` observing.) When accessing the property value from `PartialObject<O>`, make sure to use `PartialObject<O>.primitiveValue(for:)` instead of `PartialObject<O>.value(for:)`, which would unintentionally execute the same closure again recursively.
@@ -340,8 +331,8 @@ public enum TransformableContainer<O: CoreStoreObject> {
public init(
_ keyPath: KeyPathString,
initial: @autoclosure @escaping () -> V? = nil,
isIndexed: Bool = false,
isTransient: Bool = false,
allowsExternalBinaryDataStorage: Bool = false,
versionHashModifier: @autoclosure @escaping () -> String? = nil,
renamingIdentifier: @autoclosure @escaping () -> String? = nil,
customGetter: ((_ partialObject: PartialObject<O>) -> V?)? = nil,
@@ -350,8 +341,8 @@ public enum TransformableContainer<O: CoreStoreObject> {
self.keyPath = keyPath
self.defaultValue = initial
self.isIndexed = isIndexed
self.isTransient = isTransient
self.allowsExternalBinaryDataStorage = allowsExternalBinaryDataStorage
self.versionHashModifier = versionHashModifier
self.renamingIdentifier = renamingIdentifier
self.customGetter = customGetter
@@ -421,8 +412,8 @@ public enum TransformableContainer<O: CoreStoreObject> {
internal let keyPath: KeyPathString
internal let isOptional = true
internal let isIndexed: Bool
internal let isTransient: Bool
internal let allowsExternalBinaryDataStorage: Bool
internal let versionHashModifier: () -> String?
internal let renamingIdentifier: () -> String?
internal let defaultValue: () -> Any?
@@ -476,33 +467,24 @@ public enum TransformableContainer<O: CoreStoreObject> {
private let customGetter: ((_ partialObject: PartialObject<O>) -> V?)?
private let customSetter: ((_ partialObject: PartialObject<O>, _ newValue: V?) -> Void)?
// MARK: Deprecated
@available(*, deprecated: 3.2, renamed: "init(_:initial:isIndexed:isTransient:versionHashModifier:renamingIdentifier:customGetter:customSetter:affectedByKeyPaths:)")
@available(*, unavailable, message: "Indexes are now set through the Entity<T> initializer, which now supports compound indexes.")
public convenience init(
_ keyPath: KeyPathString,
`default`: @autoclosure @escaping () -> V? = nil,
isIndexed: Bool = false,
initial: @autoclosure @escaping () -> V? = nil,
isIndexed: Bool,
isTransient: Bool = false,
allowsExternalBinaryDataStorage: Bool = false,
versionHashModifier: @autoclosure @escaping () -> String? = nil,
renamingIdentifier: @autoclosure @escaping () -> String? = nil,
customGetter: ((_ partialObject: PartialObject<O>) -> V?)? = nil,
customSetter: ((_ partialObject: PartialObject<O>, _ newValue: V?) -> Void)? = nil,
affectedByKeyPaths: @autoclosure @escaping () -> Set<String> = []) {
self.init(
keyPath,
initial: `default`,
isIndexed: isIndexed,
isTransient: isTransient,
versionHashModifier: versionHashModifier,
renamingIdentifier: renamingIdentifier,
customGetter: customGetter,
customSetter: customSetter,
affectedByKeyPaths: affectedByKeyPaths
)
fatalError()
}
}
}

View File

@@ -103,7 +103,6 @@ public enum ValueContainer<O: CoreStoreObject> {
```
- parameter keyPath: the permanent attribute name for this property.
- parameter initial: the initial value for the property when the object is first created
- parameter isIndexed: `true` if the property should be indexed for searching, otherwise `false`. Defaults to `false` if not specified.
- parameter isTransient: `true` if the property is transient, otherwise `false`. Defaults to `false` if not specified. The transient flag specifies whether or not a property's value is ignored when an object is saved to a persistent store. Transient properties are not saved to the persistent store, but are still managed for undo, redo, validation, and so on.
- parameter versionHashModifier: used to mark or denote a property as being a different "version" than another even if all of the values which affect persistence are equal. (Such a difference is important in cases where the properties are unchanged but the format or content of its data are changed.)
- parameter renamingIdentifier: used to resolve naming conflicts between models. When creating an entity mapping between entities in two managed object models, a source entity property and a destination entity property that share the same identifier indicate that a property mapping should be configured to migrate from the source to the destination. If unset, the identifier will be the property's name.
@@ -114,7 +113,6 @@ public enum ValueContainer<O: CoreStoreObject> {
public init(
_ keyPath: KeyPathString,
initial: @autoclosure @escaping () -> V,
isIndexed: Bool = false,
isTransient: Bool = false,
versionHashModifier: @autoclosure @escaping () -> String? = nil,
renamingIdentifier: @autoclosure @escaping () -> String? = nil,
@@ -123,7 +121,6 @@ public enum ValueContainer<O: CoreStoreObject> {
affectedByKeyPaths: @autoclosure @escaping () -> Set<String> = []) {
self.keyPath = keyPath
self.isIndexed = isIndexed
self.isTransient = isTransient
self.defaultValue = { initial().cs_toQueryableNativeType() }
self.versionHashModifier = versionHashModifier
@@ -197,8 +194,8 @@ public enum ValueContainer<O: CoreStoreObject> {
internal let keyPath: KeyPathString
internal let isOptional = false
internal let isIndexed: Bool
internal let isTransient: Bool
internal let allowsExternalBinaryDataStorage = false
internal let versionHashModifier: () -> String?
internal let renamingIdentifier: () -> String?
internal let defaultValue: () -> Any?
@@ -256,11 +253,11 @@ public enum ValueContainer<O: CoreStoreObject> {
// MARK: Deprecated
@available(*, deprecated: 3.2, renamed: "init(_:initial:isIndexed:isTransient:versionHashModifier:renamingIdentifier:customGetter:customSetter:affectedByKeyPaths:)")
@available(*, unavailable, message: "Indexes are now set through the Entity<T> initializer, which now supports compound indexes.")
public convenience init(
_ keyPath: KeyPathString,
`default`: @autoclosure @escaping () -> V,
isIndexed: Bool = false,
initial: @autoclosure @escaping () -> V,
isIndexed: Bool,
isTransient: Bool = false,
versionHashModifier: @autoclosure @escaping () -> String? = nil,
renamingIdentifier: @autoclosure @escaping () -> String? = nil,
@@ -268,17 +265,7 @@ public enum ValueContainer<O: CoreStoreObject> {
customSetter: ((_ partialObject: PartialObject<O>, _ newValue: V) -> Void)? = nil,
affectedByKeyPaths: @autoclosure @escaping () -> Set<String> = []) {
self.init(
keyPath,
initial: `default`,
isIndexed: isIndexed,
isTransient: isTransient,
versionHashModifier: versionHashModifier,
renamingIdentifier: renamingIdentifier,
customGetter: customGetter,
customSetter: customSetter,
affectedByKeyPaths: affectedByKeyPaths
)
fatalError()
}
}
@@ -324,7 +311,6 @@ public enum ValueContainer<O: CoreStoreObject> {
```
- parameter keyPath: the permanent attribute name for this property.
- parameter initial: the initial value for the property when the object is first created. Defaults to `nil` if not specified.
- parameter isIndexed: `true` if the property should be indexed for searching, otherwise `false`. Defaults to `false` if not specified.
- parameter isTransient: `true` if the property is transient, otherwise `false`. Defaults to `false` if not specified. The transient flag specifies whether or not a property's value is ignored when an object is saved to a persistent store. Transient properties are not saved to the persistent store, but are still managed for undo, redo, validation, and so on.
- parameter versionHashModifier: used to mark or denote a property as being a different "version" than another even if all of the values which affect persistence are equal. (Such a difference is important in cases where the properties are unchanged but the format or content of its data are changed.)
- parameter renamingIdentifier: used to resolve naming conflicts between models. When creating an entity mapping between entities in two managed object models, a source entity property and a destination entity property that share the same identifier indicate that a property mapping should be configured to migrate from the source to the destination. If unset, the identifier will be the property's name.
@@ -340,7 +326,6 @@ public enum ValueContainer<O: CoreStoreObject> {
public init(
_ keyPath: KeyPathString,
initial: @autoclosure @escaping () -> V? = nil,
isIndexed: Bool = false,
isTransient: Bool = false,
versionHashModifier: @autoclosure @escaping () -> String? = nil,
renamingIdentifier: @autoclosure @escaping () -> String? = nil,
@@ -349,7 +334,6 @@ public enum ValueContainer<O: CoreStoreObject> {
affectedByKeyPaths: @autoclosure @escaping () -> Set<String> = []) {
self.keyPath = keyPath
self.isIndexed = isIndexed
self.isTransient = isTransient
self.defaultValue = { initial()?.cs_toQueryableNativeType() }
self.versionHashModifier = versionHashModifier
@@ -422,8 +406,8 @@ public enum ValueContainer<O: CoreStoreObject> {
internal let keyPath: KeyPathString
internal let isOptional = true
internal let isIndexed: Bool
internal let isTransient: Bool
internal let allowsExternalBinaryDataStorage = false
internal let versionHashModifier: () -> String?
internal let renamingIdentifier: () -> String?
internal let defaultValue: () -> Any?
@@ -481,11 +465,11 @@ public enum ValueContainer<O: CoreStoreObject> {
// MARK: Deprecated
@available(*, deprecated: 3.2, renamed: "init(_:initial:isIndexed:isTransient:versionHashModifier:renamingIdentifier:customGetter:customSetter:affectedByKeyPaths:)")
@available(*, unavailable, message: "Indexes are now set through the Entity<T> initializer, which now supports compound indexes.")
public convenience init(
_ keyPath: KeyPathString,
`default`: @autoclosure @escaping () -> V? = nil,
isIndexed: Bool = false,
initial: @autoclosure @escaping () -> V? = nil,
isIndexed: Bool,
isTransient: Bool = false,
versionHashModifier: @autoclosure @escaping () -> String? = nil,
renamingIdentifier: @autoclosure @escaping () -> String? = nil,
@@ -493,17 +477,7 @@ public enum ValueContainer<O: CoreStoreObject> {
customSetter: ((_ partialObject: PartialObject<O>, _ newValue: V?) -> Void)? = nil,
affectedByKeyPaths: @autoclosure @escaping () -> Set<String> = []) {
self.init(
keyPath,
initial: `default`,
isIndexed: isIndexed,
isTransient: isTransient,
versionHashModifier: versionHashModifier,
renamingIdentifier: renamingIdentifier,
customGetter: customGetter,
customSetter: customSetter,
affectedByKeyPaths: affectedByKeyPaths
)
fatalError()
}
}
}