Afnetworking

link post:  http://stackoverflow.com/questions/7623275/afnetworking-post-request 
link get :
http://stackoverflow.com/questions/19875886/how-to-set-http-request-using-afnetworking-2


post:
 afnetworking 2.0

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *params = @{@"user[height]": height,
                         @"user[weight]": weight};
[manager POST:@"https://example.com/myobject" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error: %@", error);
}];
 get:

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
[manager GET:@"https://example.com" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
    // do whatever you'd like here; for example, if you want to convert 
    // it to a string and log it, you might do something like:

    NSString *string = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
    NSLog(@"%@", string);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error: %@", error);
}];

You can also use AFHTTPRequestOperation:
NSOperationQueue *networkQueue = [[NSOperationQueue alloc] init];
networkQueue.maxConcurrentOperationCount = 5;

NSURL *url = [NSURL URLWithString:@"https://example.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
    // do whatever you'd like here; for example, if you want to convert 
    // it to a string and log it, you might do something like:

    NSString *string = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
    NSLog(@"%@", string);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"%s: AFHTTPRequestOperation error: %@", __FUNCTION__, error);
}];
[networkQueue addOperation:operation];
 
 
Previous
Next Post »

5 comments

Write comments
Unknown
AUTHOR
16 November 2016 at 18:47 delete

soap : https://drive.google.com/open?id=0B9iYp_BYG46LYnozSUpjQjVvaHotSEJ5bTZkMzFIRmxkaHFz

https://drive.google.com/open?id=0B9iYp_BYG46LR0w0cXc5Um14X3Z4RXdGTjEzUWprSVhJTV9r

https://drive.google.com/open?id=0B9iYp_BYG46LUzdoNzBxc1hKU05BeVRuOEsyOXhFMm5fSGlB

Reply
avatar
Unknown
AUTHOR
17 November 2016 at 19:20 delete

https://drive.google.com/open?id=0BwU5Y4Xqfa42QnRoT3JOckJ4U2M

https://drive.google.com/open?id=0BwU5Y4Xqfa42OWE2UTBUaTB5VDQ

https://drive.google.com/open?id=0BwU5Y4Xqfa42Y0JIWEdkbENzSDg

Reply
avatar
Unknown
AUTHOR
23 November 2016 at 22:23 delete

https://drive.google.com/open?id=0BwU5Y4Xqfa42SVhIMURGSTZNSkE xml

Reply
avatar
Unknown
AUTHOR
6 December 2016 at 21:09 delete

https://drive.google.com/file/d/0BwU5Y4Xqfa42UllCZUpsUF9xdXM/view?usp=drivesdk

Reply
avatar
Unknown
AUTHOR
9 June 2017 at 04:12 delete

AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager GET:URL parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
NSLog(@"JSON: %@", responseObject);
NSLog(@"////*****************************************************");
NSMutableArray *h=[[NSMutableArray alloc]init];
NSMutableArray *add=[[NSMutableArray alloc]init];
for (int i=0; i<=4; i++) {


h=[[[[[responseObject objectForKey:@"feed"]objectForKey:@"entry"]objectAtIndex:i]objectForKey:@"im:name"]objectForKey:@"label"];
NSLog(@"%@",h);
[add addObject:h];
NSLog(@"%@",add);
}



} failure:^(NSURLSessionTask *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];


}

Reply
avatar