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:
- @ Interface ZCTest ()
- @ Property (assign, nonatomic, getter = isExecuting) BOOL executing;
- @ Property (assign, nonatomic, getter = isFinished) BOOL finished;
- @ End
- @ Implementation ZCTest
- -(Id) init
- {
- If (self = [super init])
- {
- _ Executing = NO;
- _ Finished = NO;
- }
- Return self;
- }
- @ 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
^