MIBadgeButton-Swift icon indicating copy to clipboard operation
MIBadgeButton-Swift copied to clipboard

Crash when setting the badgeString

Open Isuru-Nanayakkara opened this issue 7 years ago • 2 comments

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.

Isuru-Nanayakkara avatar Jul 07 '17 11:07 Isuru-Nanayakkara

Got the same problem, solve it by programmatically create the MIBadgeButton in viewDidLoad.

xuehaoze avatar Sep 06 '17 19:09 xuehaoze

The problem is with Custom class Module, @Isuru-Nanayakkara you didn't selected Module. Changing the module to MIBadgeButton_Swift will solve your problem. screen shot 2017-10-20 at 1 41 05 am

hamzaansari09 avatar Oct 19 '17 20:10 hamzaansari09