【问题标题】:RESTFull Architecture HTTP GET & PUT Requests [closed]RESTFull 架构 HTTP GET 和 PUT 请求 [关闭]
【发布时间】:2013-07-05 15:27:47
【问题描述】:

谁能指点我有关 http 请求、GET、PUT 的教程、示例或文档。

我需要将 JSON 包放入和从 URL 中获取。

找不到太多关于从 HTTP 请求接收 JSON 的客观 C 信息。

感谢任何帮助。

【问题讨论】:

  • 看看 RestKit。
  • 是的,RestKit 会派上用场的。

标签: objective-c restful-url restful-architecture


【解决方案1】:

使用AFnetworking 是最好的主意。

下面是一个例子。

 NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys:emailUITextView.text, @"email",  passwordUITextView.text,@"password",  customerType,@"usertype", nil];
    NSURL *url = [NSURL URLWithString: BASE_URL];
    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];

    [httpClient postPath:@"/sign_in" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"Success : %@", operation.responseString);
        if([operation.responseString isEqualToString:@"true"])
            NSLog(@"Signed In successfully");         
        else if ([operation.responseString isEqualToString:@"false"])
            NSLog(@"Signed In unsuccessfully");
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Failure : %@", error);
        UIAlertView *alert = [[ UIAlertView alloc]initWithTitle:@"Error" message:[error localizedDescription] delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
        [alert show];
    }];         

【讨论】:

    猜你喜欢
    • 2011-05-02
    • 2012-10-21
    • 2022-01-11
    • 1970-01-01
    • 1970-01-01
    • 2019-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多