在将名为“ localFilePath”的String属性添加到名为GenericAttachment的Core Data实体后,当我们尝试映射这些对象的Set时,我们开始获取异常。
我们的几个实体与GenericAttachment的无序集合之间有一对多的关系,称为“附件”。
这些实体之一称为InspectionMO。GenericAttatchment与InspectionMO具有一对多的“检查”关系(不是“检查”,哎呀)。当我们获得InspectionMO的附件并尝试在其上进行映射时,会出现以下异常:
NSInternalInconsistencyException
I/O error for database at /Users/justingarcia/Library/Developer/CoreSimulator/Devices/D075B44C-4F54-4703-8817-3DC4A6E7314E/data/Containers/Data/Application/F425E5AC-C215-4BE8-93DB-A3E6C48C83C4/Library/Application Support/Procore/Procore. SQLite error code:1, 'no such column: t1.Z_55ATTACHMENTS5'
Run Code Online (Sandbox Code Playgroud)
这是异常堆栈跟踪:
#0 0x000000010c94f705 in objc_exception_throw ()
#1 0x000000010e928f00 in -[NSSQLiteConnection prepareSQLStatement:] ()
#2 0x000000010ea99305 in -[NSSQLiteConnection selectRowsWithStatement:cached:] ()
#3 0x000000010e941d0b in newFetchedRowsForFetchPlan_MT ()
#4 0x000000010eb6e574 in _newFetchedPKsForRelationshipFaultRequest ()
#5 0x000000010eb6efba in _executeNewValuesForRelationshipFaultRequest ()
#6 0x000000010ead19a2 in -[NSSQLRelationshipFaultRequestContext executeRequestCore:] ()
#7 0x000000010eb40a00 in -[NSSQLStoreRequestContext executeRequestUsingConnection:] ()
#8 0x000000010eb14e5b in __52-[NSSQLDefaultConnectionManager handleStoreRequest:]_block_invoke ()
#9 0x000000011b25f602 in _dispatch_client_callout ()
#10 0x000000011b26d653 in _dispatch_lane_barrier_sync_invoke_and_complete …Run Code Online (Sandbox Code Playgroud) 使用Swift 4.1(Xcode 9.3)我正在尝试创建一组[Int],但我得到:
类型'[Int]'不符合协议'Hashable'
但据我所知,https://swift.org/blog/conditional-conformance/表示只要其值符合Hashable,Array现在就符合Hashable.作为一种解决方法,我有:
extension Array: Hashable where Element == Int {
public var hashValue: Int {
return debugDescription.hashValue
}
}
Run Code Online (Sandbox Code Playgroud)
但我仍然想知道为什么我不能免费获得Hashable.