Post

Replies

Boosts

Views

Activity

Reply to NSMutableAttributedString initialisation to prevent crash
I faced a similar issue after enabled DarkMode - yes we've only enabled it recently. Turned out when the App went to background it was trying to take a snapshot of the top view, which I suspect is required by DarkMode, and will layout the views again, hence calling the NSAttributedString initWithData in my cell constructing method. I could see that this crash happened during App is backgrounded in Crashlytics, even tho it's still on main thread. I could also reproduce it easily once I figured it out. The fix is pretty straightforward: to use a lazy var to init that attributedStr to prevent it from being called again when the App goes to background.
Dec ’20