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
link get :
http://stackoverflow.com/
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];
Sign up here with your email
5 comments
Write commentssoap : https://drive.google.com/open?id=0B9iYp_BYG46LYnozSUpjQjVvaHotSEJ5bTZkMzFIRmxkaHFz
Replyhttps://drive.google.com/open?id=0B9iYp_BYG46LR0w0cXc5Um14X3Z4RXdGTjEzUWprSVhJTV9r
https://drive.google.com/open?id=0B9iYp_BYG46LUzdoNzBxc1hKU05BeVRuOEsyOXhFMm5fSGlB
https://drive.google.com/open?id=0BwU5Y4Xqfa42QnRoT3JOckJ4U2M
Replyhttps://drive.google.com/open?id=0BwU5Y4Xqfa42OWE2UTBUaTB5VDQ
https://drive.google.com/open?id=0BwU5Y4Xqfa42Y0JIWEdkbENzSDg
https://drive.google.com/open?id=0BwU5Y4Xqfa42SVhIMURGSTZNSkE xml
Replyhttps://drive.google.com/file/d/0BwU5Y4Xqfa42UllCZUpsUF9xdXM/view?usp=drivesdk
ReplyAFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
Reply[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);
}];
}
ConversionConversion EmoticonEmoticon