Want to use two tableView in one viewController but it give me error like:
this class is not key value coding-compliant for the key tableView.
I have two tableView 1.)tableViewTwo and 2.)tableViewThree but not wokring.
but when i used the name tableView then data shows on the first tableView.
and how can i use the different custom cell on both tableView. (CustomerListCell for (First TableView) and CustomerListCellThree for (Second TableView)
Can anyone please suggest me the best way to do this. I have search a lot and trying many suggestion which i found on internet and stackoverflow.
Thanks In Advanced.
- (void)viewDidLoad
{
NSURLRequest *requestTwo=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://xyzt.com?key=init"]];
responseData=[[NSMutableData alloc]init];
urlConnection=[[NSURLConnection alloc]initWithRequest:requestTwo delegate:self];
NSURLRequest *requestThree=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://xyzt.com?key=init"]];
responseDataThree=[[NSMutableData alloc]init];
urlConnectionThree=[[NSURLConnection alloc]initWithRequest:requestThree delegate:self];
}
#pragma mark - Connection Details
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
if (connection == urlConnection) {
NSLog(@"Error");
}
else if (connection == urlConnectionThree){
NSLog(@"Error");
}
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
if (connection == urlConnection) {
[responseData setLength:0];
}
else if (connection == urlConnectionThree){
[responseDataThree setLength:0];
}
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
if (connection == urlConnection) {
[responseData appendData:data];
}
else if (connection == urlConnectionThree) {
[responseDataThree appendData:data];
}
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
if (connection == urlConnection) {
NSError *error=nil;
NSDictionary *dic=[NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error];
self.totalData=[dic objectForKey:@"data"];
totalTitle=[[NSMutableArray alloc]init];
totalImage=[[NSMutableArray alloc]init];
totalIdWorks=[[NSMutableArray alloc]init];
[_tableViewTwo reloadData];
}
else if (connection == urlConnectionThree){
NSError *error=nil;
NSDictionary *dic=[NSJSONSerialization JSONObjectWithData:responseDataThree options:NSJSONReadingMutableContainers error:&error];
self.totalDataThree=[dic objectForKey:@"data"];
totalTitleThree=[[NSMutableArray alloc]init];
totalImageThree=[[NSMutableArray alloc]init];
totalIdWorksThree=[[NSMutableArray alloc]init];
[_tableViewThree reloadData];
}
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView == self.tableViewTwo) {
return [totalData count];
}
else if (tableView == self.tableViewThree){
return [totalDataThree count];
}
return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 40;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"CustomerListCell";
CustomerListCell *cell = (CustomerListCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomerListCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
return cell;
}