I have a dictionary having following details
{
Name = "American Airlines";
Picture = (
""
);
Rate = 3;
},
And i want to show the name on label of cell...for which i am doing following code:
-(void)viewWillAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getDetail:) name:@"NewNotification" object:nil];
}
-(void)getDetail:(NSNotification *)notification
{
if([notification.name isEqualToString:@"NewNotification"])
{
NSDictionary *dictionary=notification.userInfo;
NSLog(@"Dictionary %@",dictionary);
userInfo=dictionary;
[self.listView reloadData];
}
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
//return [userInfo count];
return 115;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellIdentifier=@"cell";
TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell== nil) {
cell = [[TableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.Name.text =[userInfo valueForKey:@"Name"];
NSLog(@"the cell.Name.text is %@",cell.Name.text);
//[cell updateCell:userInfo];
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 75;
}
I can't understand what I'm doing wrong in the code as it crashes and doesn't show anything on label.It give the exception
"Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI length]: unrecognized selector sent to instance 0x7bea2d20'"
Please check the code and tell me where am I going wrong!