mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 08:26:27 +00:00
(main): Wrap it with an NSAutoreleasePool.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1086 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1b6a1efebb
commit
dde3532e32
1 changed files with 26 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
|
||||
@interface Observer : NSObject
|
||||
- (void) gotNotificationFoo: not;
|
||||
|
@ -31,6 +32,9 @@ int main ()
|
|||
{
|
||||
id o1 = [NSObject new];
|
||||
id observer1 = [Observer new];
|
||||
id arp;
|
||||
|
||||
arp = [NSAutoreleasePool new];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: observer1
|
||||
|
@ -44,6 +48,7 @@ int main ()
|
|||
name: foo
|
||||
object: nil];
|
||||
|
||||
|
||||
/* This will cause two messages to be printed, one for each request above. */
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: foo
|
||||
|
@ -54,5 +59,26 @@ int main ()
|
|||
postNotificationName: foo
|
||||
object: nil];
|
||||
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
removeObserver: observer1
|
||||
name: nil
|
||||
object: o1];
|
||||
|
||||
/* This will cause message to be printed. */
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: foo
|
||||
object: o1];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
removeObserver: observer1];
|
||||
|
||||
/* This will cause no messages to be printed. */
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: foo
|
||||
object: o1];
|
||||
|
||||
[arp release];
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue