Problem in selecting row of table in view subclass technique
In my application i have table view cells.When i select one cell it takes me corresponding views according to selected cells. I开发者_StackOverflow have implemented it using custom subclass of UITableViewCell i.e. subclassing of cells with nib file rather then subviews using code.
I used NSDictionary to feed my cells data like below on viewDidLoad method
NSDictionary *row1=[[NSDictionary alloc]initWithObjectsAndKeys:@"Mac", @"Name", @"1.5", @"Rate", nil];
NSDictionary *row2=[[NSDictionary alloc]initWithObjectsAndKeys:@"MINI", @"Name", @"14.4",@"Rate", nil]; NSArray *array=[[NSArray alloc]initWithObjects:row1, row2 nil];
self.computers=array;
and in didSelectRowAtIndexPath method i use
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (childController==nil) {
childController=[[computerConverter alloc]initWithNibName:@"computerController" bundle:nil];
childController.title=@"Select computer to convert";
NSUInteger row=[indexPath row];
NSString *selectedComputer=[self.computers objectAtIndex:row];
NSString *detailMassage=[[NSString alloc]initWithFormat:@"%@",selectedComputer];
childController.massage =detailMassage;
childController.title=selectedComputer;
[detailMassage release];
[self.navigationController pushViewController:childController animated:YES];
childController =nil;
}
}
It shows NSException and does not take me to another corresponding view. Any suggestion will highly appreciated.
row1 and row2 are dictionaries and hence you cannot do this
childController.title=selectedComputer;
You may want to set the returned value for a key from this dictionary. I guess the problem is in the above line.
精彩评论