Skip to content

Commit 4bc8815

Browse files
committed
Quick fix to placeHolder crash, removal of bang operator.
1 parent 9dc8536 commit 4bc8815

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

Spring/DesignableTextField.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import UIKit
2626

2727
@IBInspectable public var placeholderColor: UIColor = UIColor.clear {
2828
didSet {
29-
attributedPlaceholder = NSAttributedString(string: placeholder!, attributes: [NSAttributedStringKey.foregroundColor: placeholderColor])
29+
guard let placeholder = placeholder else { return }
30+
attributedPlaceholder = NSAttributedString(string: placeholder, attributes: [NSAttributedStringKey.foregroundColor: placeholderColor])
3031
layoutSubviews()
3132

3233
}
@@ -83,12 +84,12 @@ import UIKit
8384
@IBInspectable public var lineHeight: CGFloat = 1.5 {
8485
didSet {
8586
let font = UIFont(name: self.font!.fontName, size: self.font!.pointSize)
86-
let text = self.text
87+
guard let text = self.text else { return }
8788

8889
let paragraphStyle = NSMutableParagraphStyle()
8990
paragraphStyle.lineSpacing = lineHeight
9091

91-
let attributedString = NSMutableAttributedString(string: text!)
92+
let attributedString = NSMutableAttributedString(string: text)
9293
attributedString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: attributedString.length))
9394
attributedString.addAttribute(NSAttributedStringKey.font, value: font!, range: NSRange(location: 0, length: attributedString.length))
9495

Spring/DesignableTextView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ import UIKit
4545
@IBInspectable public var lineHeight: CGFloat = 1.5 {
4646
didSet {
4747
let font = UIFont(name: self.font!.fontName, size: self.font!.pointSize)
48-
let text = self.text
48+
guard let text = self.text else { return }
4949

5050
let paragraphStyle = NSMutableParagraphStyle()
5151
paragraphStyle.lineSpacing = lineHeight
5252

53-
let attributedString = NSMutableAttributedString(string: text!)
53+
let attributedString = NSMutableAttributedString(string: text)
5454
attributedString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: attributedString.length))
5555
attributedString.addAttribute(NSAttributedStringKey.font, value: font!, range: NSRange(location: 0, length: attributedString.length))
5656

0 commit comments

Comments
 (0)