In my ios app I have created one NSModel Object for displaying tableList and when I tapped on tableList row I want to take that particular model class object data to another class
How can I do this?
my code:
NSMutableArray * mainArray;
//TableList Delegate Methods:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return mainArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"HistoryCell";
// Similar to UITableViewCell, but
UITableViewCell *cell = (UITableViewCell *)[MaintableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
model1 = mainArray[indexPath.row];
cell.textLabel.text = model1.Name;
cell.detailTextLabel.text = model1.MasterId;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
ViewController1 *Controller = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController1"];
Controller.indexPosition = indexPath.row;
[self.navigationController pushViewController:Controller animated:YES];
}
@end
ModelObject1:
#import "ModelObject1.h"
@implementation ModelObject1
@synthesize MasterId,Name;
-(void)loadingservices :(id)mainDictionary{
NSLog(@"loadingservices %@",mainDictionary);
Name = [mainDictionary objectForKey:@"Name"];
MasterId = [mainDictionary objectForKey:@"MasterId"];
}
@end