RESTFull Architecture HTTP GET & PUT Requests [closed]

旧时模样 提交于 2019-12-23 06:08:19

问题


Could anybody point me to a tutorial, examples or docs about http request, GET, PUT.

I need to put & get a JSON package to & from a URL.

Cant find much objective-c information about receiving JSONs from a HTTP request.

Any help is appreciated.


回答1:


Using AFnetworking Would best Idea.

here is the following example.

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


来源:https://stackoverflow.com/questions/17492327/restfull-architecture-http-get-put-requests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!