-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathItemsBuilder.swift
35 lines (30 loc) · 1.09 KB
/
ItemsBuilder.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
//
// ItemsBuilder.swift
// Eject
//
// Created by Brian King on 11/29/16.
// Copyright © 2016 Brian King. All rights reserved.
//
import Foundation
struct ItemsBuilder: Builder, ContainerBuilder {
func buildElement(attributes: inout [String: String], document: XIBDocument, parent: Reference?) throws -> Reference? {
guard let parent = parent else { throw XIBParser.Error.needParent }
return parent
}
func didAddChild(object: Reference, to parent: Reference, document: XIBDocument) throws {
guard !document.placeholders.contains(object.identifier) else {
// If the object is a placeholder, assume that it has already been added to the view hierarchy.
return
}
try document.addStatement(
for: object.identifier,
generator: VariableConfiguration(
objectIdentifier: parent.identifier,
key: "items",
value: VariableValue(objectIdentifier: object.identifier),
style: .append
),
phase: .generalAssignment
)
}
}