그래서 작업 엔티티 클래스 (핵심 데이터)가 있고 해당 문자열 (timeIntervalString) 중 하나에 대한 설정자를 덮어 쓰려고하므로 세부 텍스트 레이블에 표시 될 수 있습니다 표보기 셀의.잘 모르겠 음이 EXC_BAD_ACCESS 오류
-(NSString *)timeIntervalString{
NSUInteger seconds = (NSUInteger)round(self.timeInterval);
if ((seconds/3600) == 0){
if (((seconds/60) % 60) == 1) {
self.timeIntervalString = [NSString stringWithFormat:@"%u MIN", ((seconds/60) % 60)];
} else {
self.timeIntervalString = [NSString stringWithFormat:@"%u MINS", ((seconds/60) % 60)];
}
} else if ([self.conversionInfo hour] == 1) {
if (((seconds/60) % 60) == 0){
self.timeIntervalString = [NSString stringWithFormat:@"%u HR", (seconds/3600)];
} else if (((seconds/60) % 60) == 1) {
self.timeIntervalString = [NSString stringWithFormat:@"%u HR %u MIN", (seconds/3600), ((seconds/60) % 60)];
} else {
self.timeIntervalString = [NSString stringWithFormat:@"%u HR %u MINS", (seconds/3600), ((seconds/60) % 60)];
}
} else {
if (((seconds/60) % 60) == 0) {
self.timeIntervalString = [NSString stringWithFormat:@"%u HRS ", (seconds/3600)];
} else if (((seconds/60) % 60) == 1){
self.timeIntervalString = [NSString stringWithFormat:@"%u HRS %u MIN", (seconds/3600), ((seconds/60) % 60)];
} else {
self.timeIntervalString = [NSString stringWithFormat:@"%u HRS %u MINS", (seconds/3600), ((seconds/60) % 60)];
}
}
return self.timeIntervalString;
: 여기
내 코드는 ...
에서 [작업은 timeIntervalString] 37355 같은 때까지 계속된다 : 어떤 이유로 나는이 같은 EXC_BAD_ACCESS 오류를 받고 있어요
}
아이디어가 있으십니까?
반 관련 디자인 질문 :이 메서드 정의 외부에서 timeIntervalString 값을 설정 했습니까? timeIntervalString 값을 반환하는 것보다 읽기 전용 속성으로 표시해야하는지 여부에 대해서도 생각해보십시오. –
아니오 실제로 설정하지 마십시오. 표시 만합니다. 하지만 시간 간격을 설정하지 마십시오 – EvilAegis
Esker가 말한 줄에 따라이 값을'_timeIntervalString'에 저장할 필요는 없을 것입니다. 귀하의 속성을 읽기 전용 및 동적으로 선언하고 지정을 건너 뛰고 서식이 지정된 값을 반환합니다. 이렇게하면 불필요한 인스턴스 변수에서 일부 메모리를 절약 할 수 있습니다. –