HttpClient setReachabilityStatusChangedBlock declares no interface

隐身守侯 提交于 2019-12-23 16:09:26

问题


Trying to use AFNetworkings ReachabilityStatusChanged but getting

"No visible @interface for HTTPCLIENT declares the selector setReachabilityStatusChangeBlock"

But HttpClient has that function. Anyone know why this is happening?

AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://stat-api.herokuapp.com/"]];
[client setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status){

    NSLog(@"%d", status);

}];

/// UPDATE ///////////

Here is my .pch file

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "NSDate+Helper.h"
#import "NSEntityDescription+RKAdditions.h"
#import "UIAlertView+MKBlockAdditions.h"
#import "UIActionSheet+MKBlockAdditions.h"
#import "MKBlockAdditions.h"
#import "NSObject+MKBlockAdditions.h"
#import "NSString+Extra.h"
#import "UIView+Additions.h"
#import "ObjectiveSugar.h"
#import "NSNotificationCenter+UniqueNotif.h"
#import "STUIColor+Custom.h"
#import "NSObject+STNSObjectAdditions.h"
#import "UIView+Gradientcy.h"
#import "NSString+USStateMap.h"
#import "STUITextField.h"
#import "UIImage+UIImageCrop.h"
#import "UIBorderLabel.h"
#import <SystemConfiguration/SystemConfiguration.h>



#endif

回答1:


Move

#import <SystemConfiguration/SystemConfiguration.h>

right after this line:

#ifdef __OBJC__



回答2:


Are you sure you're using a version of AFNetworking that have this method?

Also, check this warning from the docs:

Warning: This method requires the SystemConfiguration framework.

Add it in the active target’s “Link Binary With Library” build phase, and add #import <SystemConfiguration/SystemConfiguration.h> to the header prefix of the project (Prefix.pch).



来源:https://stackoverflow.com/questions/17334237/httpclient-setreachabilitystatuschangedblock-declares-no-interface

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!