이전 3 시간 동안이 오류를 알아 내기 위해 노력하고 있습니다. 검색을 통해이 오류가 메모리 관리와 관련되어 있음을 알게되었지만 잘못된 것을 알지 못했습니다.nscfstring 텍스트 인식 할 수없는 선택기를 인스턴스로 보냈습니다
나는이 네 레이블을 선언 한 :
@interface InteractiveHistory : UITableViewController {
UILabel *date;
UILabel *startTime;
UILabel *cal;
UILabel *duration;
}
그런 다음 생성 된 속성을하고이를 합성.
나는 또한의 dealloc에서 그들을 해제 한date = [[UILabel alloc] init];
() 메소드의 viewDidLoad에서,이 같은 모든 초기화.
내가하고 싶은 것은이 4 개의 라벨을 사용하여 테이블의 셀에 텍스트를 쓰는 것입니다. 텍스트는 indexPath에 의존합니다. cellForRowAtIndexPath 방법에
, 그냥이 라벨을 보여 및 오류 라인 나타낼 :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
NSLog(@"constructing cell");
//set up labels text
date = [NSString stringWithFormat:@"%@",[[int_data objectAtIndex:indexPath.row] objectForKey:@"Date"]];
NSLog(@"%@",date.text); //App crashes at this line
[date setTag:1];
startTime = [NSString stringWithFormat:@"%@",[[int_data objectAtIndex:indexPath.row] objectForKey:@"Start Time"]];
//setting tag and position of label
[startTime setTag:2];
CGRect labelpos = startTime.frame;
labelpos.origin.y = date.bounds.size.height + 2;
startTime.frame = labelpos;
NSLog(@"labels set");
// Configure the cell...
[[cell contentView] addSubview:date];
[[cell contentView] addSubview:startTime];
[[cell contentView] addSubview:duration];
[[cell contentView] addSubview:cal];
NSLog(@"A cell set");
}
return cell;
}
아무도 PLZ 내가 뭘 잘못 말해 줄 수 있습니까? 내 질문은 분명하다 바랍니다 ..
+1은 startTime과 동일합니다. – danh
내 문제를 해결해 주셔서 감사합니다. 그것은 어리석은 실수 일 수있는 순간에도 내 마음 속에 오지 않았다. 고맙습니다. 그리고 당신의 요점은 절대적으로 옳습니다. – NightFury
문제 없습니다 - 우리 모두 해냈습니다! – jrtc27