1
0   YunYing                             0x0003fbc1 -[EnterpriseInfo didSelectCellRowFirstDo:nextDo:] + 993
1   YunYing                             0x0003f569 -[EnterpriseInfo tableView:didSelectRowAtIndexPath:] + 473
2   UIKit                               0x00564285 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1194
3   UIKit                               0x005644ed -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 201
4   Foundation                          0x00f6e5b3 __NSFireDelayedPerform + 380
5   CoreFoundation                      0x01b6f376 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
6   CoreFoundation                      0x01b6ee06 __CFRunLoopDoTimer + 534
7   CoreFoundation                      0x01b56a82 __CFRunLoopRun + 1810
8   CoreFoundation                      0x01b55f44 CFRunLoopRunSpecific + 276
9   CoreFoundation                      0x01b55e1b CFRunLoopRunInMode + 123
10  GraphicsServices                    0x0208c7e3 GSEventRunModal + 88
11  GraphicsServices                    0x0208c668 GSEventRun + 104
12  UIKit                               0x004b4ffc UIApplicationMain + 1211
13  YunYing                             0x0000221d main + 141
14  YunYing                             0x00002145 start + 53
)
 2013-03-25 16:52:39.867 YunYing[4242:c07] -[__NSDictionaryM isEqualToString:]:       unrecognized selector sent to instance 0x154bd020
  2013-03-25 16:52:39.868 YunYing[4242:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM isEqualToString:]:  unrecognized selector sent to instance 0x154bd020'
  *** First throw call stack:
  (0x1bb0012 0x1570e7e 0x1c3b4bd 0x1b9fbbc 0x1b9f94e 0x60de9f 0x60e064 0x3efed 0x56f8fb   0x56f9cf 0x714f30 0x71f7e2 0x55a016 0x556617 0x562945 0x562973 0x3fc26 0x3f569 0x564285 0x5644ed 0xf6e5b3 0x1b6f376 0x1b6ee06 0x1b56a82 0x1b55f44 0x1b55e1b 0x208c7e3 0x208c668 0x4b4ffc 0x221d 0x2145)
  libc++abi.dylib: terminate called throwing an exception

-[__NSDictionaryM isEqualToString:]:无法识别的选择器发送到实例

,当我调用这个方法时:[self.tableView endUpdates],代码停在这里并通过断点调试抛出错误。

我检查了我的代码,没有NSDictionary对象调用isEqualToString方法。

谢谢!以下是我的代码:我只想实现可伸缩的表格视图

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return arrayForShow.count;
}




-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{   
    if (self.isOpen) {
    if (self.selectIndex.section==section) {
        return [[[arrayForShow objectAtIndex:section]objectForKey:@"list"]count]+1;
    }
    }
    return 1; 
 }




-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:    (NSIndexPath *)indexPath
{

    if ((self.isOpen)&&(self.selectIndex.section==indexPath.section)&&(indexPath.row!=0)){
    static NSString *CellIdentifier = @"EnterpriseCell";

    EnterpriseCell *cell=(EnterpriseCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell==nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"EnterpriseCell" owner:self options:nil] objectAtIndex:0];
    }
    NSArray *enterpriseNames=[[arrayForShow objectAtIndex:indexPath.section]objectForKey:@"list"];
    cell.enterpriseName.text = [enterpriseNames objectAtIndex:indexPath.row-1];
    return cell;

}
    else
    {
    static NSString *CellIdentifier = @"CityCell";
    CityCell *cell=(CityCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell==nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"CityCell" owner:self options:nil]objectAtIndex:0];
    }
    NSString *name=[[arrayForShow objectAtIndex:indexPath.section]objectForKey:@"name"];
    cell.cityName.text=name;
    [cell changeArrowWithUp:([self.selectIndex isEqual:indexPath]? YES:NO)];

        return cell;
    }  
}




-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        if ([indexPath isEqual:self.selectIndex]) {
        self.isOpen = NO;
        [self didSelectCellRowFirstDo:NO nextDo:NO];
        self.selectIndex = nil;

        }else
        {
            if (!self.selectIndex) {
            self.selectIndex = indexPath;
            [self didSelectCellRowFirstDo:YES nextDo:NO];

            }else
            {

            [self didSelectCellRowFirstDo:NO nextDo:YES];
        }
    }

}
else
{
    NSDictionary *dic = [arrayForShow objectAtIndex:indexPath.section];
    NSArray *list = [dic objectForKey:@"list"];
    NSString *item = [list objectAtIndex:indexPath.row-1];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:item message:nil delegate:nil cancelButtonTitle:@"cancel" otherButtonTitles: nil];
    [alert show];
}

[tableView deselectRowAtIndexPath:indexPath animated:YES];

}


- (void)didSelectCellRowFirstDo:(BOOL)firstDoInsert nextDo:(BOOL)nextDoInsert
{
    self.isOpen = firstDoInsert;

    CityCell *cell = (CityCell *)[self.cityTable cellForRowAtIndexPath:self.selectIndex];
    [cell changeArrowWithUp:firstDoInsert];



   int section = self.selectIndex.section;
    int contentCount = [[[arrayForShow objectAtIndex:section] objectForKey:@"list"] count];

NSMutableArray* rowToInsert = [[NSMutableArray alloc] init];
for (NSUInteger i = 1; i < contentCount + 1; i++) {
    NSIndexPath* indexPathToInsert = [NSIndexPath indexPathForRow:i inSection:section];
    [rowToInsert addObject:indexPathToInsert];
}

[self.cityTable beginUpdates];

if (firstDoInsert)
{   [self.cityTable insertRowsAtIndexPaths:rowToInsert withRowAnimation:UITableViewRowAnimationTop];
}
else
{
    [self.cityTable deleteRowsAtIndexPaths:rowToInsert withRowAnimation:UITableViewRowAnimationTop];
}

[self.cityTable endUpdates];

    if (nextDoInsert) {
    self.isOpen = YES;
    self.selectIndex = [self.cityTable indexPathForSelectedRow];
    [self didSelectCellRowFirstDo:YES nextDo:NO];
    }
    if (self.isOpen){
    [self.cityTable scrollToNearestSelectedRowAtScrollPosition:UITableViewScrollPositionTop animated:YES];
    }

}
4

2 回答 2

2

在您的代码中的某处,您正在拨打电话isEqualToString。现在源字符串当时无效。它要么已被释放,要么现在指向 Dictionary 对象。

检查生成方法调用的字符串变量的引用isEqualToString

于 2013-03-25T08:10:55.397 回答
0

在某处您使用没有正确数据的 NSDictionaryM,因此您面临此类错误,或者您检查存储在包含 NSDictionary 的表中的值。

于 2013-03-25T08:03:11.363 回答