Hi Bart / Tomeu -I owe the community an update, and I hope this helps you, too.TLDR; preliminary findings: watch where and how you call on defaultAttributes (and any other properties) of your UITextView. Developing on newer hardware offers affordances older hardware does not.Background: my problem user runs a 2014 MacbookPro. He would report seemingly random crashes anywhere between 30-45 mins of use, with crash intervals exponentially decreasing after the first crash, limiting out around 3-5mins (i.e. first at 45mins, next at 15mins, then every 3-5 mins a crash.)I refactored my 'typingAttributes retention' methods; it appears the solution has worked. ~5days of no crashing.Here was the problem code (I'm a newb, as you can tell): func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool
if textView.selectedRange.location > 1 && textView.attributedText.length >= 2 && appeared {//viewDidAppear Bool
pullSetDefaults(at: self.selectedRange.location - 1)
}
//otherstuff//return blah
}Where pullSetDefaults: func pullSetDefaults(at: Int) {
if !(at < self.attributedText.length) {return}
var defaultsAtts = self.attributedText.attributes(at: at, effectiveRange: nil)
referenceToTextView.typingAttributes = defaultsAtts
}Well... I'm frankly dumbfounded at my idiocy. It turns out the problem was separating the textView object/references across methods, to my credit: still in the same class though. On my newer MacBook Pro, I never experienced the crashes, but I presume on older computers the calls overlap, causing a bad address error.New code that doesn't crash: func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
if textView.selectedRange.location > 1 && textView.attributedText.length >= 2 && appeared {
textView.typingAttributes = currentAttributes //(a variable computed elsewhere, still probably a bad idea)
}
//otherstuff//return blah
}I'm not brave enough to try to run the typingAttributes retention in the shouldChangeText in yet, but I imagine that would help, too, since the call to the textview isn't split across methods.Hope this helps! Cheers,Charlie
Post
Replies
Boosts
Views
Activity
Hi Steven,
Did you get this sorted? Was a DigiCert EV SSL required?
Thank you!