Marcel Gruber
Marcel Gruber

Reputation: 7495

In AFNetworking, what does #ifdef _SYSTEMCONFIGURATION_H mean?

This check is in my AFHTTPClient.m file. The check is actually used very frequently throughout the file and the .h file. In one case, it does this:

#ifdef _SYSTEMCONFIGURATION_H
  self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown;
  [self startMonitoringNetworkReachability];
#endif

This is still version 1.X of AFNetworking.

Thanks!

Upvotes: 1

Views: 381

Answers (2)

Jacek Lampart
Jacek Lampart

Reputation: 1751

To solve this problem, type #import <SystemConfiguration/SystemConfiguration.h> #import <MobileCoreServices/MobileCoreServices.h> before importing AFNetworking.

Upvotes: 0

Daniel
Daniel

Reputation: 23359

I believe this is a pre-processor statement checking that you have linked your project with the SystemConfiguration framework. If not, I believe that AFNetworking was omitting some feature, or maybe it was giving you a nice warning to make sure you don't forget to include this framework, so that AFNetworking could work as expected.

Update

#ifdef _SYSTEMCONFIGURATION_H
#import <netinet/in.h>
#import <netinet6/in6.h>
#import <arpa/inet.h>
#import <ifaddrs.h>
#import <netdb.h>
#endif

So what's going on is if _SYSTEMCONFIGURATION_H is defined (internally by the SystemConfiguration framework), then AFNetworking knows that you included this framework in your project, and so it is importing a bunch of things to make use of it. Otherwise it isn't. This means that you don't have to include this framework if you don't want to.

Upvotes: 2

Related Questions