Steps to get data from webservices Using AFnetworking..
1- Download the AFNetworking library from
http://four-developers.com/documents/afnetworking.zip
2 - If your is arc based then you have to add the following flag
-fno-objc-arc
to every afnetworking file..
3 - After that you have to import to your viewcontroller
#import "AFNetworking.h"
4 - After that :
Use following code..
-(void)AFnetworkingProcessTheRequest
{
NSURLRequest* request = [[NSURLRequest alloc]initWithURL:[NSURL URLWithString:@"http://four-developers.com/service1.svc/getdata/aa"]];
AFJSONRequestOperation* opration = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request,NSHTTPURLResponse *response,id responseObject)
{
arrData = [[NSArray alloc]initWithObjects:responseObject, nil];
[tblEmp reloadData];
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id responseObject)
{
NSLog(@"Request Failed: %@, %@", error, error.userInfo);
}];
[opration start];
}
You can download Complete sample from:
http://four-developers.com/documents/UsingAFNetWorking.zip
1- Download the AFNetworking library from
http://four-developers.com/documents/afnetworking.zip
2 - If your is arc based then you have to add the following flag
-fno-objc-arc
to every afnetworking file..
3 - After that you have to import to your viewcontroller
#import "AFNetworking.h"
4 - After that :
Use following code..
-(void)AFnetworkingProcessTheRequest
{
NSURLRequest* request = [[NSURLRequest alloc]initWithURL:[NSURL URLWithString:@"http://four-developers.com/service1.svc/getdata/aa"]];
AFJSONRequestOperation* opration = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request,NSHTTPURLResponse *response,id responseObject)
{
arrData = [[NSArray alloc]initWithObjects:responseObject, nil];
[tblEmp reloadData];
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id responseObject)
{
NSLog(@"Request Failed: %@, %@", error, error.userInfo);
}];
[opration start];
}
You can download Complete sample from:
http://four-developers.com/documents/UsingAFNetWorking.zip
No comments:
Post a Comment