Become a MacRumors Supporter for $25/year with no ads, private forums, and more!

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
I finished my app last week and then went to read through what Apple wants you to do before submitting it. That was a mistake, I should have read that stuff first and would have caught a bunch of things I did wrong like using Vimeo instead HTTP Live Stream for my video.

The last part is to test to see if an internet connection exists. So I downloaded the Reachability class from the Apple sample code.

In the sample Apple provided there are a lot of items (photo included). After looking at everything I see the only thing I need to import in to my project are the,

Reachability.h
Reachability.m


and instantiate an object from that Class. I don't think I need the the ReachabilityAppDelegate.h or .m and those are used for the demo project?

Thanks.
 

Attachments

  • Reachability.jpg
    Reachability.jpg
    38.4 KB · Views: 138

dejo

Moderator emeritus
Sep 2, 2004
15,981
451
The Centennial State
I brought in the Reachability.h and .m only to find out that it is not completable with ARC.

I did some more research and found that someone wrote as a replacement for that Class that covered ARC

You also have the option to flag files as not needing ARC. This is suitable for older libraries that don't have new versions but you still want to use. More info here: How can I disable ARC for a single file in a project?
 

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
Good to know. I like ARC but I am also glad I got a taste of doing my own memory management on a few projects. I think everyone starting to program should do projects without ARC till they get the hang of memory management.
 

Sykte

macrumors regular
Aug 26, 2010
223
0
Good to know. I like ARC but I am also glad I got a taste of doing my own memory management on a few projects. I think everyone starting to program should do projects without ARC till they get the hang of memory management.

I posted an updated reachability that supported arc in the apple forums. Not sure if it's been purged but you may want to try there.
 

xStep

macrumors 68020
Jan 28, 2003
2,021
127
Less lost in L.A.
I just implemented this into a project this week. It's easy to work around the ARC issue.

1. Click on the target.
2. Choose the Build Phases tab.
3. Reveal the Compile Sources by clicking on the triangle.
4. Double click the Reachability.m file.
5. In the pop up edit box, enter -fno-obj-arc and click Done.

While you have that panel showing.
1. Click the plus sign under the Link Binary With Libraries.
2. In the drop down panel, type the first few letters of System.
3. Select SystemConfiguration.framework
4. Click Add.

In the Reachability.h file add the following line to get rid of some warnings.
#import <netinet/in.h>

I've setup an ivar in my app delegate and make calls to that. I've also setup the notification so that I could have a little red light / green light icon that tells me when the connection is on or off.
 

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
That's good to know. So what it is doing is adding a 'Flag' of some kind to the Reachability class that tells the compiler to treat just this one class differently?

Thanks.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.