Skip to content

Crash when setting the badgeString #27

@Isuru-Nanayakkara

Description

@Isuru-Nanayakkara

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions