NSLog learning document in Objective-C

Source: Internet
Author: User

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

 
 
  1. • % @ Object
  2. • % D, % I integer
  3. • % U unsigned integer
  4. • % F floating point/double-Character
  5. • % X, % X binary integer
  6. • % O octal integer
  7. • % Zu size_t
  8. • % P pointer
  9. • % E floating point/double-word scientific computing)
  10. • % G floating point/double-Character
  11. • % S C string
  12. • %. * S Pascal string
  13. • % C characters
  14. • % C unichar
  15. • % Lld 64-bit long)
  16. • % Llu unsigned 64-bit long integer
  17. • % 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!

Related Article

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.