How to Download the Reachability Sample with ARC Code
Apple's Reachability sample application for iOS apps has been recently updated to use ARC. Here is how you use both ARC and non-ARC files in your project.
In order to have both ARC and non-ARC code in a single project, the following steps allow you to remove a file from ARC:
In the Project navigator, select the project icon at the top of the Project navigator area to display the Project editor.
In the Targets section, select your project.
Click the Build Phases tab.
You're witnessing here one of the few reasons you would ever have for using any of the other tabs in the Project editor.
Expand the Compile Sources section, as shown in this figure.
Double-click the Reachability.m file.
A window appears.
In the window’s text box, enter -fno-objc-arc, as shown; then click outside the text box to close it.
You may also have to choose Product→Clean if you tried to compile the project without doing Steps 1–6 because you wanted to see how many errors it would generate.
You have now told the compiler not to use ARC in Reachability.h and .m and that memory management is done by the Reachability code (which is what it would have been doing all along pre-ARC).
You also need to add this code to Reachability.h.
Listing: Update the Reachability Interface #import <Foundation/Foundation.h> #import <SystemConfiguration/SystemConfiguration.h> #import <netinet/in.h>