1 | //
|
---|
2 | // PSAlert.m
|
---|
3 | // Pester
|
---|
4 | //
|
---|
5 | // Created by Nicholas Riley on Sat Oct 26 2002.
|
---|
6 | // Copyright (c) 2002 Nicholas Riley. All rights reserved.
|
---|
7 | //
|
---|
8 |
|
---|
9 | #import "PSAlert.h"
|
---|
10 | #import "NSDictionary-NJRExtensions.h"
|
---|
11 |
|
---|
12 | NSString * const PSAlertCreationException = @"PSAlertCreationException";
|
---|
13 |
|
---|
14 | NSString * const PSAlarmAlertCompletedNotification = @"PSAlarmAlertCompletedNotification";
|
---|
15 |
|
---|
16 | // property list keys
|
---|
17 | static NSString * const PLAlertClass = @"class"; // NSString
|
---|
18 |
|
---|
19 | @implementation PSAlert
|
---|
20 |
|
---|
21 | + (PSAlert *)alert;
|
---|
22 | {
|
---|
23 | NSAssert(NO, @"Class is abstract");
|
---|
24 | return nil;
|
---|
25 | }
|
---|
26 |
|
---|
27 | - (void)triggerForAlarm:(PSAlarm *)alarm;
|
---|
28 | {
|
---|
29 | NSAssert(NO, @"Class is abstract");
|
---|
30 | }
|
---|
31 |
|
---|
32 | - (BOOL)requiresPesterFrontmost;
|
---|
33 | {
|
---|
34 | return NO;
|
---|
35 | }
|
---|
36 |
|
---|
37 | - (void)completedForAlarm:(PSAlarm *)alarm;
|
---|
38 | {
|
---|
39 | [[NSNotificationCenter defaultCenter] postNotificationName: PSAlarmAlertCompletedNotification object: alarm userInfo: [NSDictionary dictionaryWithObject: self forKey: @"alert"]];
|
---|
40 | }
|
---|
41 |
|
---|
42 | - (NSAttributedString *)actionDescription;
|
---|
43 | {
|
---|
44 | NSAssert(NO, @"Class is abstract");
|
---|
45 | return nil;
|
---|
46 | }
|
---|
47 |
|
---|
48 | #pragma mark property list serialization (Pester 1.1)
|
---|
49 |
|
---|
50 | - (NSDictionary *)propertyListRepresentation;
|
---|
51 | {
|
---|
52 | return [NSDictionary dictionaryWithObject: NSStringFromClass([self class]) forKey: PLAlertClass];
|
---|
53 | }
|
---|
54 |
|
---|
55 | - (id)initWithPropertyList:(NSDictionary *)dict;
|
---|
56 | {
|
---|
57 | if ( (self = [self init]) != nil) {
|
---|
58 | IMP myImp = [self methodForSelector: _cmd];
|
---|
59 | NSString *clsString = [dict objectForRequiredKey: PLAlertClass];
|
---|
60 | Class cls = NSClassFromString(clsString);
|
---|
61 | NSAssert1(cls != nil, @"Alert class %@ is not available", clsString);
|
---|
62 | [super release];
|
---|
63 | self = [cls alloc];
|
---|
64 | if (self != nil) {
|
---|
65 | IMP subImp = [self methodForSelector: @selector(initWithPropertyList:)];
|
---|
66 | NSAssert1(subImp != myImp, @"No implementation of initWithPropertyList: for alert class %@", clsString);
|
---|
67 | self = [self initWithPropertyList: dict];
|
---|
68 | }
|
---|
69 | }
|
---|
70 | return self;
|
---|
71 | }
|
---|
72 |
|
---|
73 | @end
|
---|