mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-25 01:01:21 +01:00
Fix bug saving related objects for articles — authors, tags, and attachments.
This commit is contained in:
parent
a5c1bf41cb
commit
b5d8233955
@ -114,6 +114,28 @@ extension Article: DatabaseObject {
|
||||
return articleID
|
||||
}
|
||||
}
|
||||
|
||||
public func relatedObjectsWithName(_ name: String) -> [DatabaseObject]? {
|
||||
|
||||
switch name {
|
||||
case RelationshipName.authors:
|
||||
return databaseObjectArray(with: authors)
|
||||
case RelationshipName.tags:
|
||||
return databaseObjectArray(with: tags)
|
||||
case RelationshipName.attachments:
|
||||
return databaseObjectArray(with: attachments)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
private func databaseObjectArray<T: DatabaseObject>(with objects: Set<T>?) -> [DatabaseObject]? {
|
||||
|
||||
guard let objects = objects else {
|
||||
return nil
|
||||
}
|
||||
return Array(objects)
|
||||
}
|
||||
}
|
||||
|
||||
extension Set where Element == Article {
|
||||
|
Loading…
Reference in New Issue
Block a user