Hello everybody!
I've found out that maxCount is taken into account only when we call the setCount method, unfortunately, this constant doesn't apply for calls of increment. Example:
hub.setMaxCount(99)
hub.increment(by: 150)
// count == 150
Compare their implementations to each other. increment:
/// Increases count by 1
public func increment() {
increment(by: 1)
}
/// Increases count by amount.
/// - Parameter amount: Increment count.
public func increment(by amount: Int) {
count += amount
}
setCount:
/// Set the count yourself.
/// - Parameter newCount: New count to be set to badge.
public func setCount(_ newCount: Int) {
self.count = newCount
let labelText = count > maxCount ? "\(maxCount)+" : "\(count)"
countLabel?.text = labelText
checkZero()
}
Hello everybody!
I've found out that maxCount is taken into account only when we call the
setCountmethod, unfortunately, this constant doesn't apply for calls ofincrement. Example:Compare their implementations to each other.
increment:setCount: