MIBadgeButton-Swift
MIBadgeButton-Swift copied to clipboard
Crash when setting the badgeString
Hi,
I installed the library through CocoaPods. Added a UIButton
(just an image, no text) and set its class to MIBadgeButton
. I didn't do any modifications through the IB.
Then I tried to increase the badge count every time the button is pressed. But when setting the badge string, the app crashes with a EXC_BAD_ACCESS error.
Below is my code.
import UIKit
import MIBadgeButton_Swift
class ViewController: UIViewController {
@IBOutlet weak var button: MIBadgeButton!
var count = 0
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func didTapButton(_ sender: MIBadgeButton) {
count = count + 1
sender.badgeString = "\(count)"
}
}
I also uploaded a demo project here.
Got the same problem, solve it by programmatically create the MIBadgeButton in viewDidLoad.
The problem is with Custom class Module, @Isuru-Nanayakkara you didn't selected Module.
Changing the module to MIBadgeButton_Swift will solve your problem.