2013-07-23 2 views
0

Почему EXC_BAD_ADRESS сгенерирован после выполнения команды willSelectRowAtIndexPath и до того, как был сделанSelectRowAtIndexPath ?? Без реализации willSelectRowAtIndexPath он отлично работает.EXC_BAD_ADRESS сгенерирован после выполнения команды willSelectRowAtIndexPath

Вот мой код:

- (void)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     KMWTableViewCell *cell = (KMWTableViewCell *) [tableView cellForRowAtIndexPath:indexPath]; 
     if(cell){ 
      cell.visibleView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cellBackPressed.png"]]; 
     } 
    } 

    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     KMWTableViewCell *cell = (KMWTableViewCell *) [tableView cellForRowAtIndexPath:indexPath]; 
     if(cell){ 
      [self setCurrentAccountId:[[[KMWAppDelegate accounts] objectAtIndex:indexPath.section] objectForKey:@"accountId"]]; 
      [self performSegueWithIdentifier:@"services" sender:self]; 
     } 
    } 
+0

На какой линии он падает? –

+0

Где-то между этими методами. Не в моем коде. –

+1

'willSelectRowAtIndexPath:' должен возвращать 'NSIndexPath'. – Desdenova

ответ

5

Метод подпись является неправильной. Это возвращаемое значение должно быть NSIndexPath:

- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    KMWTableViewCell *cell = (KMWTableViewCell *) [tableView cellForRowAtIndexPath:indexPath]; 
    if(cell){ 
     cell.visibleView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cellBackPressed.png"]]; 
    } 

    return indexPath; 
} 

В вашей реализации вы, наконец, необходимо вернуть данную indexPath.