-
Notifications
You must be signed in to change notification settings - Fork 4
/
Collection+CoreDataProperties.swift
65 lines (52 loc) · 1.38 KB
/
Collection+CoreDataProperties.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// Collection+CoreDataProperties.swift
// iOS
//
// Created by Tinashe on 2021/02/25.
//
//
import Foundation
import CoreData
extension Collection {
@nonobjc public class func fetchRequest() -> NSFetchRequest<Collection> {
return NSFetchRequest<Collection>(entityName: "Collection")
}
@NSManaged public var about: String?
@NSManaged public var created: Date?
@NSManaged public var id: UUID?
@NSManaged public var title: String?
@NSManaged public var hymns: NSSet?
}
// MARK: Generated accessors for hymns
extension Collection {
@objc(addHymnsObject:)
@NSManaged public func addToHymns(_ value: Hymn)
@objc(removeHymnsObject:)
@NSManaged public func removeFromHymns(_ value: Hymn)
@objc(addHymns:)
@NSManaged public func addToHymns(_ values: NSSet)
@objc(removeHymns:)
@NSManaged public func removeFromHymns(_ values: NSSet)
}
extension Collection : Identifiable {
var wrappedTitle: String {
title ?? ""
}
var wrappedDescription: String {
about ?? ""
}
var allHymns: [Hymn] {
let set = hymns as? Set<Hymn> ?? []
return set.sorted {
$0.wrappedTitle < $1.wrappedTitle
}
}
func containsHymn(id: UUID) -> Bool {
for item in allHymns {
if item.id == id {
return true
}
}
return false
}
}