Cause Analysis (SDWebImageDownloaderOperation. m error) and Xcode6 pre-compile

Source: Internet
Author: User

Cause Analysis (SDWebImageDownloaderOperation. m error) and Xcode6 pre-compile

I wrote an article about how to compile SDWebImage to report an error:

Http://blog.csdn.net/cuibo1123/article/details/39434015

As a result, many people asked the reason for this question. Let's talk about it here and send it together with the analysis ideas (but I suggest you do it yourself ).

First, if you create a new project, declare the output port and reference it in the form of SDWebImage:

  1. @ Interface ZCTest ()
  2. @ Property (assign, nonatomic, getter = isExecuting) BOOL executing;
  3. @ Property (assign, nonatomic, getter = isFinished) BOOL finished;
  4. @ End
  5. @ Implementation ZCTest
  6. -(Id) init
  7. {
  8. If (self = [super init])
  9. {
  10. _ Executing = NO;
  11. _ Finished = NO;
  12. }
  13. Return self;
  14. }
  15. @ End

This Code does not have any problems and can be compiled normally.

Why are the following prompts in SDWebImage for the same code?

Use of undeclared identifier '_ executing ';
Use of undeclared identifier '_ finished ';


The idea is to find the SDWebImageDownloaderOperation class of SDWebImage and what is the difference between the class and your own code. It is easy to find that the parent class inherited by SDWebImageDownloaderOperation is NSOperation, so we will inherit our own test code from NSOperation. You will find that the test code will report the same error. Okay, the cause is located in NSOperation. Let's take a look at this interface and open NSOperation. h. In the declaration, we will find the following two lines:


@ Property (readonly, getter = isExecuting) BOOL executing;

@ Property (readonly, getter = isFinished) BOOL finished;


Well, the problem lies here. NSOperation declares two attributes with the same name and is readonly. Therefore, an error is returned when _ executing = NO is used in SDWebImageDownloaderOperation, in the extension of SDWebImageDownloaderOperation, the priority of using assign is lower than that of inheritance (speculation ). This is the source of the problem.


As for why xcode of the old version does not report an error, it may come down to xcode itself. Maybe the declaration of readonly mode of the old version also produces _ executing, however, xcode6 optimized the _ executing variable in readonly mode. If you are interested, you can test the variable yourself or check the compilation process file. I will not continue to explain it here.


Original content, reproduced please indicate the source: http://blog.csdn.net/cuibo1123

^


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.