This is What it Means
Josh Russell
Josh Russell
Snippet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var syncedEntities = [Syncable]()
for document in snapshot.documents {
let data = document.data()
guard let uidStr = data[discoverableType.uidKey] as? String,
let uid = UUID(uuidString: uidStr) else {
logger.warning("Invalid UID Field in fetched discoverable for uidKey: '\(discoverableType.uidKey)'")
continue
}
let dataObject: Syncable
if let existingObject = discoverableType.find(inMoc: moc, uid: uid) {
dataObject = existingObject
} else {
dataObject = discoverableType.create(withUid: uid, moc: moc)
}
_ = dataObject.syncFromServer(data: data)
syncedEntities.append(dataObject)
}