CustomHttpRequest.h
@protocol CustomHTTPRequestDelegate
@required
-(void) receivedDataForURL : (NSString *) reqUrl resultData: (NSDictionary *) result_;
@end
@property (retain) id delegate;
CustomHttpRequest.m
[[self delegate] receivedDataForURL:urlStr resultData:dic];
—–
.h
@interface VCAtm : UIViewController {
}
.m
CustomHttpRequest *httpReq = [[CustomHttpRequest alloc] initWithURL:url];
httpReq.delegate = self;
#pragma mark –
#pragma mark CustomHttpRequest Delegate
-(void) receivedDataForURL : (NSString *) reqUrl resultData:(NSDictionary *) result_{
NSLog(@”reqURL %@”, reqUrl);
NSLog(@”result data %@”, result_);
//show all values
for (id key in result_) {
id value = [result_ objectForKey:key];
NSString *keyAsString = (NSString *)key;
NSString *valueAsString = (NSString *)value;
NSLog(@”key: %@”, keyAsString);
NSLog(@”value: %@”, valueAsString);
}
NSArray *results = [result_ objectForKey:@”results”];
for (NSDictionary *result in results) {
NSString *name = [result objectForKey:@”name”];
[nameList addObject:name];
NSLog(@”Name : %@”, name);
}
atmTableView.delegate = self;
atmTableView.dataSource = self;
[atmTableView reloadData];
}