A small hole in the use of IOS block

Source: Internet
Author: User

1. First paragraph of the Code

     __block  typeof(self) tmpself = self ;    [TableView addlegendheaderwithrefreshingblock:^() {        [tmpself initdata:no];    }];

Write the time did not pay much attention, the back of the test when found every push to this page memory is constantly increasing, and more regular, consider the memory leaks, with static and dynamic analysis did not find

Memory leaks, but the memory is constantly growing, the next thought is not released, the breakpoint under the dealloc found really did not execute, and then a variety of inspection agent to see the wood has a circular reference, a circle to look down

My Special Agent basic use of weak decoration is not likely to follow the circular reference, there is no way to only comment on the viewdidload function of the various methods, finally found the problem, is the above code, sense

Feel good pit, later write code or serious point, this error is very silent, it is difficult to find this problem, hope that will not make such a mistake.

2. The correct wording

typeof (self) tmpself = self ;    [TableView addlegendheaderwithrefreshingblock:^() {        [tmpself initdata:no];    }];

A small hole in the use of IOS block

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.