Objective-CMediumNSLogThe Learning document is the content of this article.NSLogOutput format.NSLogFor more information about the impact on program performance, see.
NSLog output format
- • % @ Object
- • % D, % I integer
- • % U unsigned integer
- • % F floating point/double-Character
- • % X, % X binary integer
- • % O octal integer
- • % Zu size_t
- • % P pointer
- • % E floating point/double-word scientific computing)
- • % G floating point/double-Character
- • % S C string
- • %. * S Pascal string
- • % C characters
- • % C unichar
- • % Lld 64-bit long)
- • % Llu unsigned 64-bit long integer
- • % Lf 64-bit dual-Text
Impact of NSLog on Program Performance
NSLog allows you to easily format the output as printf does, and output time, process ID, and other information. It is a debugging tool. but in fact, NSLog also has a significant impact on program performance. When the number of executions is relatively small, what may not be seen, when a large amount of execution is performed in a short time, the execution efficiency of the program will be significantly affected.
One of the situations I encountered was that I output many logs in the layoutSubviews METHOD OF A UIScrollView subclass, And the layoutSubviews itself had a relatively heavy workload to do, since every time you drag this UIScrollView, you have to call the layoutSubviews many times. Therefore, the drag experience of the program is very poor, resulting in severe freezing, after multiple tests, we found that it was normal to comment out all nslogs and drag them.
To sum up, if you are confused about what causes your program to run poorly, comment out those nslogs and try again. Your problem may be solved.
-- You can package a function such as debuglog and put it under # ifdef DEBUG.
Summary:Objective-CMediumNSLogI hope this article will help you understand the content of this document!