Код: Выделить всё
*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: NSFont)
Код: Выделить всё
public final class HotelListPresentation {
public init() {
prepareRating()
}
private func prepareRating() {
// Rating Status
if let commentCount = hotel.commentCount, let ratingtext = hotel.averageScoreText {
let commentText = (commentCount >= 3 ? " (\(commentCount) \(TextKey.hotelComment.localized))" : "")
let boldFont = UIFont.systemFont(ofSize: 15, weight: .bold)
let regularFont = UIFont.systemFont(ofSize: 12)
let titleColor = UIColor.blue
let mutableAttributedString = NSMutableAttributedString()
mutableAttributedString.append(NSAttributedString(string: ratingtext, attributes: [.font: boldFont, .foregroundColor: titleColor]))
mutableAttributedString.append(NSAttributedString(string: commentText, attributes: [.font: regularFont, .foregroundColor: titleColor]))
self.ratingStatusAttributed = mutableAttributedString
}
}
}
public final class HotelListTableViewCell: UITableViewCell {
@IBOutlet private var starsComponent: HotelStarsComponent!
@IBOutlet private var ratingStackView: UIStackView!
@IBOutlet private var ratingLabel: Label!
@IBOutlet private var ratingBackgroundView: UIView!
@IBOutlet private var ratingStatusLabel: Label!
func configure(with data: HotelListPresentation) {
let rating = data.averageScore ?? 0
ratingLabel.text = rating.ratingDescription
ratingBackgroundView.tintColor = data.averageScoreColor
ratingStackView.isHidden = rating == 0 ? true : false
ratingStatusLabel.attributedText = data.ratingStatusAttributed // Crash line
}
}
Вот журнал крашлитика,
Код: Выделить всё
Fatal Exception: NSInvalidArgumentException
*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: NSFont)
0
CoreFoundation
__exceptionPreprocess
1
libobjc.A.dylib
objc_exception_throw
2
CoreFoundation
-[__NSDictionaryM setObject:forKey:]
3
CoreFoundation
-[NSMutableDictionary addEntriesFromDictionary:]
4
Foundation
-[NSMutableAttributedString addAttributes:range:]
5
Foundation
-[NSAttributedString enumerateAttributesInRange:options:usingBlock:]
6
UIKitCore
-[NSAttributedString _ui_synthesizeAttributedSubstringFromRange:usingDefaultAttributes:]
7
UIKitCore
-[UILabel _synthesizedAttributedTextForContent:]
8
UIKitCore
-[UILabel _synthesizedAttributedText]
9
UIKitCore
-[UILabel _textRectForBounds:limitedToNumberOfLines:includingShadow:]
10
UIKitCore
-[UILabel _intrinsicSizeWithinSize:]
11
UIKitCore
-[UILabel _ensureBaselineMetricsReturningBounds]
12
UIKitCore
-[UILabel _baselineOffsetFromBottom]
13
UIKitCore
-[UILabel _invalidateBaselineConstraints]
14
UIKitCore
-[UILabel _setContent:adjustingFontForAccessibilityTraits:adjustingFontForTypesettingLanguage:adjustingFontForTypesettingLanguageAwareLineHeightRatio:checkingForDifferences:]
15
UIKitCore
-[UILabel _setContent:]
16
UIKitCore
-[UILabel setAttributedText:]
17
obilet
HotelListTableViewCell.swift - Line 130
specialized HotelListTableViewCell.configure(with:imageSliderDataSource:) + 130
18
HotelApp
closure #1 in HotelListView.tableDataSource.getter
Подробнее здесь: https://stackoverflow.com/questions/790 ... abel-on-io