Reputation: 133
In 3.0 Afnetworking I am copying AFNetworking, UIKit+AFNetworking and importing AFNetworking.h but getting error
I want to know how to implement Afnetworking without pod
Could some one help me on this...
AFHTTPRequestOperationManager * manager =[[AFHTTPRequestOperationManager alloc]init];
[manager POST:@"http://192.168.1.92/Abdul/Json/student.json" parameters:@"" success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"RESULT .. %@",responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"ERR .. %@",error);
}];
Upvotes: 1
Views: 603
Reputation: 82779
if you using latest verson of afnetwork 3.x
NSURL *URL = [NSURL URLWithString:@"http://192.168.1.92/Abdul/Json/student.json"];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager POST:URL.absoluteString parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(NSURLSessionTask *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
if you using oldest verson of afnetwork 2.x
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager POST:@"http://192.168.1.92/Abdul/Json/student.json" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
Note
check once are you imported the header file
#import <AFNetworking/AFHTTPRequestOperationManager.h> // or #import "AFHTTPRequestOperationManager.h"
Upvotes: 2