iOS Child Threading Action UI issue check

Source: Internet
Author: User

In iOS development, because most of the functions are not thread-safe, it is very dangerous to manipulate the UI in a UI sub-thread, but sometimes because the developer is inexperienced, doesn't know that the UI is not in the child thread, or knows but does not notice when writing the code, Or do not know those functions to manipulate the UI (such as the UITableView reload function), causing this problem often occurs, hard to prevent, and iOS is not like Android, once the sub-thread operation UI directly crashes, iOS operating UI is only possible to collapse, causing problems often not reproduce, And often the stack is chaotic, can not find the place where the error, very headache.

I wrote a simple thread to check the UI operation of the library, when the child threads manipulate the UI, depending on the macro definition CRASH (view_op_inspect_crash) or the print stack (view_op_inspect_log_stack (not conflicting), the rationale is to replace most of the UIView's API with the runtime's Class_replacemethod (Given the performance issue, the get operation has no replace), Then check in the function of replace to see if the current thread is the main one.

GitHub address is https://github.com/pualxiao/PXViewOpInspect (just written out of a library, constantly perfected in, tap. Welcome comments and suggestions, and participate in the completion of the code)

The use of the method is very simple, put PXViewOpInspect.h and PXVIEWOPINSPECT.M in the project can be, if defined View_op_inspect_crash and View_op_inspect_log_ A macro in the stack will replace the UIView API, and no one will.

For performance issues, it is recommended that you use this library in debug mode, with no view_op_inspect_crash and View_op_inspect_log_stack defined under release.

  

iOS Child Threading Action UI issue check

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.