Search code examples
iosexc-bad-access

EXC_BAD_ACCEss code=1error when populating UILabel text property


I'm setting the text for a label, but it sometimes crashes with,

EXC_BAD_ACCESS (code=1, adress=xxxxxxxxx)

and when it doesnt crash the labels shows this

"Friday 10:00 AM - 10:50 AM - (action=longDelayRecognizer:, target=<UITextInteractionAssistant 0x1701d4280>)""

or this

- -2.312090474116815e+16"

this is how im populating the view

  guard let breakoutTime = self.classSelected?.breakout?.breakoutShortFormatTimes(),
        let breakoutDay = self.classSelected?.breakout?.getBreakoutDay()
        else {
            return
    }
    self.title = String(format:"%@ %@ - %@", breakoutDay, breakoutTime)

so im not sure what to make of this. Any help is appreciatted


Solution

  • The line

    self.title = String(format:"%@ %@ - %@", breakoutDay, breakoutTime)
    

    contains three placeholders %@ %@ - %@ but only two arguments breakoutDay, breakoutTime.

    The number of placeholders must match the number of arguments.