我有以下細節異常而顯示在自定義單元格,從詞典數據
{
Name = "American Airlines";
Picture = (
""
);
Rate = 3;
},
一本字典,我想表現出細胞的標籤上的名字......對此我做下面的代碼:
-(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 *[email protected]"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;
}
我不明白我在代碼中做錯了,因爲它崩潰,並且不顯示在label.It給任何異常
「終止應用程序由於未捕獲的異常‘NSInvalidArgumentException’,原因是:‘ - [__ NSArrayI長]:無法識別的選擇發送到實例0x7bea2d20’」
請檢查代碼,並告訴我,我該怎麼錯在何處!
添加特殊的斷點並查看它在哪裏崩潰。 –
要知道如何添加特殊的突破點,你可以看到http://stackoverflow.com/questions/17802662/exception-breakpoint-in-xcode。它很容易做到。 –