Original address: http://blog.163.com/kefan_1987/blog/static/89780131201371211132188/
SDK4.0 introduced the arc, and it's been a year now and it's starting to find that there are a lot of projects that mix these two scenarios. Like what:
1. The old project did not use arc, but the introduction of the third party library is the use of arc.
2. Arc was used for its new project, but the introduction of Third-party libraries or previously written code did not use arc.
In both cases, the direct affirmation is not compiled. You can do this by upgrading the old project to use arc, but this is sometimes cumbersome.
An easy way to do this is to specify whether a single file is compiled with arc.
The method is in build phase inside compile source inside find the need for special processing files, plus the compilation option (Compiler Flags), specifically for the above two different situations.
1. For the first case, add the-FOBJC-ARC option to the source file that uses arc
2. For the second case, add-fno-objc-arc
In addition, Xcode seems to have a problem, click on a source file compiler flags entries, should show the cursor where there is no hint, the input character also has no echo, only after the knock, select other files to see the added compilation options ... This is really no word.
For a new variety of plug-ins to write, you can do this:
-(void) dealloc{
//do Something in common
#if!__has_feature (OBJC_ARC)
[Super Dealloc];
#else
//nothing
#endif
}
Make it available in both arc and non-arc.