SANetworkHelper makes your life easier to test network connection on a iOS device without having to spend time writing lots of code. Its has a few simple class methods that run in a background thread and return the response of the network by either using Block or Delegate.
Example method with Block:
[SANetworkTester googleDNSWithCompletion:^(NSNumber *response) {
// handle success
[self showAlert:[NSString stringWithFormat:@"Received %@ packets", response]];
} errorHandler:^(NSString *address, NSError *error) {
// handle error
[self showAlert:[NSString stringWithFormat:@"Failed %@ wError: %@", address, error.localizedDescription]];
}];
Example method with Delegate:
- #import < SANetworkTester.h >
- add Delegate to class:
- add two optional protocol methods: - (void)didFailToReceiveResponseFromAddress:(NSString *)address withError:(NSError *)error; and - (void)didReceiveResponse:(NSNumber *)response;
- add method to run test: [SANetworkTester googleDnsWithDelegate:self];
To run the example project; clone the repo, and build the exmaple project.
- you need help, use Stack Overflow. (Tag 'SANetworkTester')
- you'd like to ask a general question, use Stack Overflow.
- you found a bug, and can provide steps to reliably reproduce it, open an issue.
- you have a feature request, open an issue.
- you want to contribute, submit a pull request.
SANetworkTester is available through CocoaPods, to install it simply add the following line to your Podfile:
pod "SANetworkTester"
Or directly drag and drop the Source folder and add these framework: 'CFNetwork', 'MobileCoreServices', 'SystemConfiguration'
shams-ahmed, [email protected]
SANetworkTester is available under the MIT license. See the LICENSE file for more info.