NHRequest 1.0.1

NHRequest 1.0.1

测试已测试
语言语言 Objective-CObjective C
许可证 MIT
发布最后发布2014 年 12 月

未声明 维护。



NHRequest 1.0.1

  • Nathn Hegedus

它是一个与 AFNetworking 一起使用以进行类似 POST、PUT、GET 和 DELETE 的 HTTP 请求的接口

设置

  1. 将 AFNetwork 添加到您的项目中
  2. 导入 “NHRequest.h”, #import "NHRequest.h"

如何使用?

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