我有一个countryViewController
,其中包含列出了不同国家/地区的tableView
。单击此按钮将转到phraseViewController
。当您第一次单击它时,这可以正常工作,但是当我按下countryViewController
中的一行时再次按下并再次测试时。它给了我以下错误:
由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:' - [phraseObject name]:无法识别的选择器发送到实例0x948cd60'
为什么我会收到此错误?当它第一次运作时。
代码:
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict
{
if ([elementName isEqualToString:@"phrase"]) {
translation = attributeDict[@"translation"];
meaning = attributeDict[@"meaning"];
pronounce = attributeDict[@"pronounce"];
theId = attributeDict[@"id"];
object = [phraseObject new];
object.translation = translation;
object.meaning = meaning;
object.pronounce = pronounce;
object.soId = theId;
theObject = [noSearchObject new];
theObject.translation = translation;
theObject.meaning = meaning;
theObject.pronounce = pronounce;
theObject.soId = theId;
[finalArray addObject:object];
[noSearchArray addObject:theObject];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableViewData dequeueReusableCellWithIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.backgroundColor = [UIColor clearColor];
cell.accessoryView = [[ UIImageView alloc ]
initWithImage:[UIImage imageNamed:@"play2.png" ]];
if (tableView == self.searchDisplayController.searchResultsTableView) {
phraseObject *object = self.filterTheArray[indexPath.row];
cell.textLabel.text = [NSString stringWithFormat:@"%@", object.meaning];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@", object.translation];
}
else{
noSearchObject *theObject = filteredArray[indexPath.row];
cell.textLabel.text = [NSString stringWithFormat:@"%@", theObject.meaning];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@", theObject.translation];
}
return cell;
}