Added ARC Compatibility#1
Conversation
|
At this time, I am not accepting patches to move this code to ARC. This is so that the code can maintain backwards compatibility for users who have not yet moved to ARC. I'll keep the pull request open, however, and when I do convert it to ARC, I'll close it. Thanks for the pull request anyway though. |
|
Thanks for your reply. If you look at my commit, I added macros to take care of the compatibility. My commit is 100% backwards-compatible---so no changes are required on the part of those who've not made the move to ARC. |
|
Yeah, I absolutely appreciate what you did there. However, the macros actually make me less likely to use this patch directly. This partially falls over into a philosophical issue. One which I may or may not be in the minority on, but here goes: #1. I feel that preprocessor macros are generally a "bad thing". They're a tool, and a very valuable tool when you need them, but they should be used only as a last resort in these kinds of situations. In this case, a much better tool is simply to disable ARC for these files when you add them to your project. This is simple to do, and doesn't clutter the code. #2. Even if I wanted to include preprocessor macros for making this code compatible with ARC or not, preprocessor macros that define retain/release replacements are generally a "very bad thing", and should be avoided at all costs. You should never, ever do this. #3. An appropriate use of macros, in this case, might be to use the __has_feature(objc_arc) macro to determine if ARC is NOT enabled in a file which requires it so that you can display a compiler error to alert the user that they should enable ARC for that file. Since release/retain/dealloc cause errors when compiled with ARC, no such macro is needed for files that have not been converted to ARC. |
|
We do have a philosophical disagreement, but it's your project and I respect your wishes. Thanks for your time! |
I added some macros to check for ARC usage and, if not enabled, call normal release on the blocks you're owning. The code should work on both ARC and non-ARC projects.