2014-04-14 1 views
2

여러 메서드와 관련된 다른 질문을 읽었지 만 여전히 코드 수정 방법을 모릅니다. 나는이 도움에 감사 할 것입니다. 오류가 발생한 부분에 *을 붙였습니다. 여러분의 도움을 부탁드립니다 'location'이라는 여러 메서드가 결과, 매개 변수 유형 또는 특성이 일치하지 않음을 발견했습니다.

NSDateFormatter *df = [[NSDateFormatter alloc] init]; 
    [df setDateFormat: @"dd-MM-yy HH:mm"]; 
    NSString *startDateString = [df stringFromDate:[[self.eventsList 
    objectAtIndex:indexPath.row] startDate]]; 

    cell.startDateLabel.text = startDateString; 

    NSString *endDateString = [df stringFromDate:[[self.eventsList 
    objectAtIndex:indexPath.row] endDate]]; 


    cell.endDateLabel.text = endDateString; 

    return cell; 
    } 



cell.locationLabel.text = [[self.eventsList objectAtIndex:indexPath.row] location]; 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: 
     (NSIndexPath *)indexPath 
    { 
    static NSString *CellIdentifier = @"eventCell"; 
    EQCalendarCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) 
    { 
     cell = [[EQCalendarCell alloc] initWithStyle:UITableViewCellStyleDefault 
     reuseIdentifier:CellIdentifier]; 
    } 
    cell.titleLabel.text = [[self.eventsList objectAtIndex:indexPath.row] title]; 

.

답변

7

self.eventsList 컬렉션에서 개체를 검색 한 결과를 전송하면 문제가 해결됩니다. 예컨대 :

cell.locationLabel.text = [((MyClassName *)[self.eventsList objectAtIndex:indexPath.row]) location];

컬렉션의 클래스의 이름으로 MyClassName 교체.

+0

감사합니다. 매우 고마워요. – user3331154

3

컴파일러에서 처리중인 데이터 유형을 알 수 있도록 관련 유형에 [self.eventsList objectAtIndex:indexPath.row]을 캐스팅해야합니다.

self.eventList 목록이 채워지는 방법을 보지 않고도 솔루션을 정확하게 말할 수는 없지만 선을 이와 같이 바꿔야합니다 (명확성을 위해 두 줄로 나눠야하지만 대신 캐스팅을 사용할 수 있습니다).

MyEventClass *event = [self.eventsList objectAtIndex:indexPath.row]; 
cell.locationLabel.text = [event location]; 
+0

감사합니다. – user3331154

1

EKEvent 클래스를 캐스팅해야합니다. 객체를 생성하는 팩토리 메소드는 다음 컴파일러는 모든 클래스에 메소드 서명을 확인합니다 유형 "ID"를 반환이 경우에, 하나 개의 시나리오에서 ...

EKEvent *event = [self.eventlist objectAtIndex:indexPath.row]; 
NSString *placeStr=[event location]; 
0

을 문제를 해결할 것입니다. 컴파일러가 둘 이상의 클래스에서 동일한 메소드 서명을 찾으면 문제가 제기 될 것입니다. 따라서 리턴 유형 "id"를 "특정 클래스 이름"으로 대체하십시오.