디버깅 흔적이 거의없이 내 앱에서 하드 크래시가 발생하는 코드 변경 사항으로 인해 버그를 파악할 수 없습니다.NSTimeInterval을 사용하여 설명 할 수없는 크래시
여기에 원래의 방법
+ (NSArray *)currentReservations {
NSTimeInterval interval = [[NSDate date] timeIntervalSince1970];
double futureTimeframe = interval + SecondsIn24Hours;
NSArray *reservations = [Reservation findWithSql:@"select * from Reservation where timestamp < ? and timestamp > ?" withParameters:[NSArray arrayWithObjects:[NSNumber numberWithDouble:ceil(futureTimeframe)], [NSNumber numberWithDouble:floor(interval)], nil]];
return reservations;
}
나는 현재와 미래의 시작 24시 사이에 타임 스탬프가 모든 레코드를 찾기 위해 데이터베이스를 조회 할 수 있도록하는 방법은 몇 가지 변수를 설정합니다. 지금과 내일 (다음 날 자정) 사이에 타임 스탬프를 가진 모든 레코드를 쿼리하는 방법을 변경해야합니다, 그래서 나는 그러나
this other stackoverflow question
+ (NSArray *)currentReservations {
NSDate *today = [NSDate date];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [[NSDateComponents alloc] init];
[components setDay:1]; // tomorrow
NSDate *tomorrow = [gregorian dateByAddingComponents:components toDate:today options:0];
// [components release]; // dont think we need this release, but it is in the example here: https://stackoverflow.com/questions/181459/is-there-a-better-way-to-find-midnight-tomorrow
NSUInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
components = [gregorian components:unitFlags fromDate:tomorrow];
[components setHour:0];
[components setMinute:0];
NSDate *tomorrowMidnight = [gregorian dateFromComponents:components];
[components release], components=nil;
[gregorian release], gregorian=nil;
NSTimeInterval interval = [today timeIntervalSince1970];
NSTimeInterval tomorrowInterval = [tomorrowMidnight timeIntervalSince1970];
NSArray *reservations = [Reservation findWithSql:@"select * from Reservation where timestamp < ? and timestamp > ?" withParameters:[NSArray arrayWithObjects:[NSNumber numberWithDouble:tomorrowInterval], [NSNumber numberWithDouble:floor(interval)], nil]];
return reservations;
}
에 기반이에 코드를 업데이트 할 때이 두 라인 :
NSTimeInterval interval = [today timeIntervalSince1970];
NSTimeInterval tomorrowInterval = [tomorrowMidnight timeIntervalSince1970];
이 포함되면 앱이 다운됩니다. 나는이 두 줄로 줄 지어 설명했다.
나는 무엇이 잘못되었는지에 대해 완전히 망한다.
"앱이 다운되는 경우"라는 의미는 무엇입니까? 어떤 방법으로? 스택 트레이스는 무엇입니까? – Jim
시뮬레이터에서 주 루프로 하드 충돌이 발생하면 – cpjolicoeur
역 추적 (디버그 콘솔에서 bt를 입력)해야합니다. "충돌"이 문제를 해결하는 데 도움이되지 않습니다. – jrturton