SubThread for UIView Control

I’m continually developing original reminder’s app. I faced one issue when showing content on view. After got reminder’s data from EventStore, tried to put it as UITextView to confirm what kind reminders we can retrieve. But UITextView has error with following message.

This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release.

This was caused by multi thread processing. Some process to display reminder text into UITextFiled after get reminder data was contained in closure of function to retrieve reminder data from EventStore with identifier. Those process was called per identifier, it means in case of multi reminder list which the device has. Then each processes to modify UITextField were in subthread.  

As solution for this, I implemented “Dispatch_sync” method by referring to Grand Central Dispatch (GCD) Reference

dispatch_sync(dispatch_get_main_queue(),
            {
                self.textfiled.text = "Sample text to show text from subthread."
            })

It was success without any error. I could learn one new thing for iOS at this time.

Leave a Reply

Your email address will not be published. Required fields are marked *