Changeset 105 for trunk/Cocoa/Pester/Source/PSAlarm.m
- Timestamp:
- 03/02/03 19:53:27 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/Pester/Source/PSAlarm.m
r103 r105 184 184 dateTime = [NSCalendarDate dateWithDate: date atTime: time]; 185 185 if (dateTime == nil) { 186 [self _beInvalid: @"Please specify a reasonable date and time."]; 186 [self _beInvalid: @"Please specify a reasonable date and time."]; return; 187 187 } 188 188 [self setForDateAtTime: dateTime]; … … 418 418 - (NSString *)description; 419 419 { 420 return [NSString stringWithFormat: @"%@: type %@ date %@ interval %.1f%@ ",420 return [NSString stringWithFormat: @"%@: type %@ date %@ interval %.1f%@%@", 421 421 [super description], [self _alarmTypeString], alarmDate, alarmInterval, 422 (repeating ? @" repeating" : @""), 422 423 (alarmType == PSAlarmInvalid ? 423 424 [NSString stringWithFormat: @"\ninvalid message: %@", invalidMessage] … … 437 438 case PSAlarmSet: 438 439 [dict setObject: [NSNumber numberWithDouble: [alarmDate timeIntervalSinceReferenceDate]] forKey: PLAlarmDate]; 439 break;440 440 case PSAlarmSnooze: 441 441 case PSAlarmInterval: 442 442 case PSAlarmExpired: 443 [dict setObject: [NSNumber numberWithDouble: alarmInterval] forKey: PLAlarmInterval];444 [dict setObject: [NSNumber numberWithBool: repeating] forKey: PLAlarmRepeating];445 443 break; 446 444 default: 447 445 NSAssert1(NO, NSLocalizedString(@"Can't save alarm type %@", "Assertion for invalid PSAlarm type on string; %@ replaced with alarm type string"), [self _alarmTypeString]); 448 446 break; 447 } 448 if ((alarmType != PSAlarmSet || repeating) && alarmType != PSAlarmDate) { 449 [dict setObject: [NSNumber numberWithBool: repeating] forKey: PLAlarmRepeating]; 450 [dict setObject: [NSNumber numberWithDouble: alarmInterval] forKey: PLAlarmInterval]; 449 451 } 450 452 if (snoozeInterval != 0) … … 474 476 case PSAlarmInterval: 475 477 case PSAlarmExpired: 476 alarmInterval = [[dict objectForRequiredKey: PLAlarmInterval] doubleValue];477 repeating = [[dict objectForRequiredKey: PLAlarmRepeating] boolValue];478 478 break; 479 479 default: … … 481 481 break; 482 482 } 483 repeating = [[dict objectForKey: PLAlarmRepeating] boolValue]; 484 if ((alarmType != PSAlarmSet || repeating) && alarmType != PSAlarmDate) 485 alarmInterval = [[dict objectForRequiredKey: PLAlarmInterval] doubleValue]; 483 486 snoozeInterval = [[dict objectForKey: PLAlarmSnoozeInterval] doubleValue]; 484 487 [self setMessage: [dict objectForRequiredKey: PLAlarmMessage]]; … … 488 491 if (alarmType == PSAlarmSet) { 489 492 alarmType = PSAlarmDate; 490 [self setTimer]; 493 // don't want to put this logic in setTimer or isValid because it can cause invalid alarms to be set (consider when someone clicks the "repeat" checkbox, then switches to a [nonrepeating, by design] date alarm, and enters a date that has passed: we do -not- want the alarm to magically morph into a repeating interval alarm) 494 if (![self setTimer] && [self isRepeating]) { 495 alarmType = PSAlarmInterval; 496 [self setInterval: [[dict objectForRequiredKey: PLAlarmInterval] doubleValue]]; 497 [self setTimer]; 498 } 491 499 } 492 500 if (alarmType == PSAlarmExpired) {
Note:
See TracChangeset
for help on using the changeset viewer.