mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
Value.Required<URL> in CoreStoreObjects crash on empty default value #141
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ThibaultVlacich on GitHub (May 28, 2017).
I'm trying the new "no .xcdatamodeld" functionality of CoreStore 4, and I have a crash when declaring a
Valueof typeURLHere is the interesting part of my model:
And here's the full crash stack trace, it crashes on
ImportableAttributeType.swift, line 568:@JohnEstropia commented on GitHub (May 28, 2017):
@ThibaultVlacich Thanks for the report. It looks like we can't use empty string on
URL, but is fine withNSURL🤔In the meantime I suggest the following workarounds:
let url = Value.Required<URL>("url", default: URL(string: "http://")!)Value.Optional<URL>insteadValue.Required<NSURL>instead (would fail if the emptyNSURLis casted toURL)In hindsight I should separate
ImportableAttributeTypes that can and cannot have "empty" values. Ill look for an elegant way for it.@JohnEstropia commented on GitHub (May 28, 2017):
@ThibaultVlacich Okay I "fixed" this in 4.0.1. Basically some types will now require the
default:argument.These "non-emptyable" types include
URL,NSURL,Date,NSDate,UUID, andNSUUID.@ThibaultVlacich commented on GitHub (May 28, 2017):
Thanks. I've choose to mark my url as Optional, a bit cleaner I think :)
@JohnEstropia commented on GitHub (May 29, 2017):
Yup, I recommend that as well. But now the compiler checks it for us :)
Closing this issue, thanks again!