A way of weakself

Source: Internet
Author: User

A long time ago to see the source of the afnetworking to find such a sentence:

1 2 3 4 5 6 7 8 9 Ten
//Do not know the use of this line of code of the students you should go to study the arc of attention and the use of block//Afnetworking __weak __typeof(&*self)weakself  = self ; //I've been writing this before. __weak __typeof(self) weakself =  Self ;//or write this __weak xxxviewcontroller *weakself =  Self ;//or write this __weak ID weakself = self; 

At that time did not notice why to write &* this appearance ... Think again today, search a lap, finally let me find the reason ...

Body

In fact, the above 4 kinds of writing are right  
Afnetworking is not written in this line of code because  typeof (self)   will be parsed into  xxxviewcontroller *const __strong   (If your self is xxxviewcontroller), Then you will get an error ... (No old version, no validation, but look at the online conclusion should be like this)

However, if you write the __typeof (self), there is no problem ... That's because there's no such situation after LLVM3.1 ... (VIA)

A way of weakself

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.