NHRequest 1.0.1

NHRequest 1.0.1

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Unclaimed.



NHRequest 1.0.1

  • By
  • Nathn Hegedus

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

Setup

  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);
    }];