I am using AfNetworking 1.0 into my app. I have create a singleton class of AFHTTPClient. following is my code;
+ (id)sharedInstance {
static WebServices *__sharedInstance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSString *WebServiceBaseURLString = [[NSUserDefaults standardUserDefaults]stringForKey:@"URL"];
__sharedInstance = [[WebServices alloc] initWithBaseURL:[NSURL URLWithString:WebServiceBaseURLString]];
});
return __sharedInstance;
}
- (id)initWithBaseURL:(NSURL *)url {
self = [super initWithBaseURL:url];
if (self) {
NSString *accessToken = [[NSUserDefaults standardUserDefaults] stringForKey:@"UserToken"];
NSLog(@"accessToken=%@",accessToken);
[self setAuthorizationHeaderWithToken:accessToken];
NSLog(@"self=%@",self);
[self registerHTTPOperationClass:[AFJSONRequestOperation class]];
self.parameterEncoding = AFJSONParameterEncoding;
[AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"application/json"]];
}
return self;
}
its working file.
But now i want to use AFNetworkReachabilityStatus block
to check the network.
[self setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status){
NSLog(@"changed %d", status);
}];
can any one advice me how to use AFNetworkReachabilityStatus block?