2013-08-18 4 views
0

완료 직전에 문제가 발생했지만 배열의 데이터를 정렬하는 정렬 시스템. 나는 그것이 나에게 오류가 있다고 말해 주지만 나는 그것을하기 위해 모든 시스템을 설정했다. 여기서 문제가되는 코드 조각이며 준다 오류 : 그것이 말하는 오류 환자에 있습니다정렬 UITableView가 작동하지 않습니다

NSArray *filteredArray = [[patients filterUsingPredicate:search] sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]]; 

과는 말한다 :

- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *cellIndentifier = @"cell"; 
    UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:cellIndentifier forIndexPath:indexPath]; 
    NSString *letter = [charIndex objectAtIndex:[indexPath section]]; 
    NSPredicate *search = [NSPredicate predicateWithFormat:@"patientName beginswith[cd] %@", letter]; 

    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"patientName" ascending:YES]; 

    NSArray *filteredArray = [[patients filterUsingPredicate:search] sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]]; 
    if (nil == cell) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; 
    } 

    NSLog(@"indexPath.row = %d, patients.count = %d", indexPath.row, patients.count); 
    Patient *thisPatient = [filteredArray objectAtIndex:[indexPath row]]; 
    cell.textLabel.text = [NSString stringWithFormat:@"%@ %@", thisPatient.patientName, thisPatient.patientSurname]; 
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
    cell.textLabel.textColor = [UIColor blackColor]; 
    if (self.editing) { 
     [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; 
    } 
    return cell; 
} 

:

Bad receiver type void 

이 컨텍스트에서 코드가 일어나는 일이 많고 그렇다면 거기에 길은 둥근 일입니까 ??? 당신은 그 결과의 메소드를 호출 할 수 있도록 사전

답변

5

filterUsingPredicate:에서

감사는 무효 방법입니다. 또한이 배열을 tableView:cellForRowAtIndexPath: 안에 필터링하지 않으려면 데이터가 엉망이됩니다. 모든 세포는 환자 일부를 버릴거야!

시도 : 내가 목표 - C 아주 새로운 오전 그렇게 할 것입니다 방법

NSArray *filteredArray = [[patients filteredArrayUsingPredicate:search] sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]]; 
+0

. 죄송합니다. – Hive7

+0

다른 코드를 입력 했으므로 대답을 변경했습니다. –

+0

감사합니다. 완벽하게 작동했습니다. – Hive7

관련 문제