API  0.9.10
CPNotification.j
Go to the documentation of this file.
1 /*
2  * CPNotification.j
3  * Foundation
4  *
5  * Created by Francisco Tolmasky.
6  * Copyright 2008, 280 North, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 
36 @implementation CPNotification : CPObject
37 {
38  CPString _name;
39  id _object;
40  CPDictionary _userInfo;
41 }
42 
50 + (CPNotification)notificationWithName:(CPString)aNotificationName object:(id)anObject userInfo:(CPDictionary)aUserInfo
51 {
52  return [[self alloc] initWithName:aNotificationName object:anObject userInfo:aUserInfo];
53 }
54 
61 + (CPNotification)notificationWithName:(CPString)aNotificationName object:(id)anObject
62 {
63  return [[self alloc] initWithName:aNotificationName object:anObject userInfo:nil];
64 }
65 
69 - (id)init
70 {
71  [CPException raise:CPUnsupportedMethodException
72  reason:"CPNotification's init method should not be used"];
73 }
74 
83 - (id)initWithName:(CPString)aNotificationName object:(id)anObject userInfo:(CPDictionary)aUserInfo
84 {
85  self = [super init];
86 
87  if (self)
88  {
89  _name = aNotificationName;
90  _object = anObject;
91  _userInfo = aUserInfo;
92  }
93 
94  return self;
95 }
96 
101 {
102  return _name;
103 }
104 
108 - (id)object
109 {
110  return _object;
111 }
112 
117 {
118  return _userInfo;
119 }
120 
121 @end
Used to implement exception handling (creating & raising).
Definition: CPException.h:2
void raise:reason:(CPString aName, [reason] CPString aReason)
Definition: CPException.j:66
A mutable key-value pair collection.
Definition: CPDictionary.h:2
id initWithName:object:userInfo:(CPString aNotificationName, [object] id anObject, [userInfo] CPDictionary aUserInfo)
An immutable string (collection of characters).
Definition: CPString.h:2
A notification that can be posted to a CPNotificationCenter.
Definition: CPNotification.h:2
CPDictionary userInfo()
id init()
Definition: CPObject.j:145
id alloc()
Definition: CPObject.j:130