Latest 1.0.1
Homepage https://github.com/nthegedus/NHRequest
License MIT
Platforms ios 7.0, requires ARC
Dependencies AFNetworking
Authors

It’s an interface with AFNetworking to make HTTP requests like POST, PUT, GET and DELETE

Setup

Installation with CocoaPods

I recommend you to take a look at CocoaPods and use it for dependency management in your iOS projects.

To add NHRequest to your project it is necessary that the following lines are in your Podfile:

platform :ios, '7.0'
pod "NHRequest", "~> 1.0.1"

Installation without CocoaPods

  1. Add the AFNetwork into your project
  2. Import "NHRequest.h", #import "NHRequest.h"

How to use?

GET:

    [[NHRequest sharedInstance] getWithURLString:@"yourURL" andHeaders:nil withBlockSuccess:^(id responseObject) {
       NSLog(@"responseObject: %@",responseObject);
    } orFailure:^(NSError *error, id responseObject) {
        NSLog(@"error: %@",error);
        NSLog(@"responseObject: %@",responseObject);
    }];

POST:

    NSDictionary *parameters = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"My name"] forKeys:[NSArray arrayWithObject:@"nameKey"]];

    [[NHRequest sharedInstance] postWithParametersAndValuesDict:parameters URLString:@"http://SomeURL.com.br" andHeaders:nil withBlockSuccess:^(id responseObject) {
        NSLog(@"responseObject: %@",responseObject);
    } orFailure:^(NSError *error, id responseObject) {
        NSLog(@"error: %@",error);
        NSLog(@"responseObject: %@",responseObject);
    }];

PUT

    NSDictionary *parameters = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"My name"] forKeys:[NSArray arrayWithObject:@"nameKey"]];

    [[NHRequest sharedInstance] putWithParametersAndValuesDict:parameters URLString:@"http://SomeURL.com" andHeaders:nil withBlockSuccess:^(id responseObject) {
        NSLog(@"responseObject: %@",responseObject);
     } orFailure:^(NSError *error, id responseObject) {
        NSLog(@"error: %@",error);
      NSLog(@"responseObject: %@",responseObject);
    }];

DELETE

    [[NHRequest sharedInstance] deleteWithURLString:@"yourURL" andHeaders:nil withBlockSuccess:^(id responseObject) {
        NSLog(@"responseObject: %@",responseObject);
    } orFailure:^(NSError *error, id responseObject) {
        NSLog(@"error: %@",error);
        NSLog(@"responseObject: %@",responseObject);
    }];

Latest podspec

{
    "name": "NHRequest",
    "version": "1.0.1",
    "summary": "It is just a simple way to make HTTP requests like POST, PUT, GET and DELETE.",
    "homepage": "https://github.com/nthegedus/NHRequest",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Nathn Hegedus": "[email protected]"
    },
    "source": {
        "git": "https://github.com/nthegedus/NHRequest.git",
        "tag": "1.0.1"
    },
    "source_files": "NHRequest/*.{h,m}",
    "dependencies": {
        "AFNetworking": [
            ">=2.0"
        ]
    },
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true
}

Pin It on Pinterest

Share This