Advertisement
Online Test Banks
Score higher
See Online Test Banks
eLearning
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

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:

  1. In the Project navigator, select the project icon at the top of the Project navigator area to display the Project editor.

  2. In the Targets section, select your project.

  3. 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.

  4. Expand the Compile Sources section, as shown in this figure.

    image0.jpg
  5. Double-click the Reachability.m file.

    A window appears.

  6. 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>
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win an iPad Mini. Enter to win now!