Skip to content

Commit bc5a15e

Browse files
committed
Use computed property instead
1 parent 23ec5ed commit bc5a15e

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

Aztec/Classes/EditorView/EditorView.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ import UIKit
66
public class EditorView: UIView {
77
public let htmlTextView: UITextView
88
public let richTextView: TextView
9-
public let htmlStorage: HTMLStorage
9+
public var htmlStorage: HTMLStorage {
10+
guard let htmlStorage = htmlTextView.textStorage as? HTMLStorage else {
11+
fatalError("If this happens, something is very off on the init config")
12+
}
13+
return htmlStorage
14+
}
1015

1116
// MARK: - Encoding / Decoding
1217

1318
static let htmlTextViewKey = "Aztec.EditorView.htmlTextView"
1419
static let richTextViewKey = "Aztec.EditorView.richTextView"
15-
static let htmlStorageKey = "Aztec.EditorView.htmlStorage"
1620

1721
// MARK: - Content Insets
1822

@@ -97,14 +101,12 @@ public class EditorView: UIView {
97101

98102
public required init?(coder aDecoder: NSCoder) {
99103
guard let htmlTextView = aDecoder.decodeObject(forKey: EditorView.htmlTextViewKey) as? UITextView,
100-
let richTextView = aDecoder.decodeObject(forKey: EditorView.richTextViewKey) as? TextView,
101-
let htmlStorage = aDecoder.decodeObject(forKey: EditorView.htmlStorageKey) as? HTMLStorage else {
104+
let richTextView = aDecoder.decodeObject(forKey: EditorView.richTextViewKey) as? TextView else {
102105
return nil
103106
}
104107

105108
self.htmlTextView = htmlTextView
106109
self.richTextView = richTextView
107-
self.htmlStorage = htmlStorage
108110

109111
if #available(iOS 11, *) {
110112
htmlTextView.smartInsertDeleteType = .no
@@ -125,7 +127,6 @@ public class EditorView: UIView {
125127
storage.addLayoutManager(layoutManager)
126128
layoutManager.addTextContainer(container)
127129

128-
self.htmlStorage = storage
129130
self.htmlTextView = UITextView(frame: .zero, textContainer: container)
130131
self.richTextView = TextView(defaultFont: defaultFont, defaultParagraphStyle: defaultParagraphStyle, defaultMissingImage: defaultMissingImage)
131132

0 commit comments

Comments
 (0)