mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +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
a0d636cfe4
commit
4b5ab43442
1 changed files with 26 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <Foundation/NSNotification.h>
|
#include <Foundation/NSNotification.h>
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
|
#include <Foundation/NSAutoreleasePool.h>
|
||||||
|
|
||||||
@interface Observer : NSObject
|
@interface Observer : NSObject
|
||||||
- (void) gotNotificationFoo: not;
|
- (void) gotNotificationFoo: not;
|
||||||
|
@ -31,6 +32,9 @@ int main ()
|
||||||
{
|
{
|
||||||
id o1 = [NSObject new];
|
id o1 = [NSObject new];
|
||||||
id observer1 = [Observer new];
|
id observer1 = [Observer new];
|
||||||
|
id arp;
|
||||||
|
|
||||||
|
arp = [NSAutoreleasePool new];
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
addObserver: observer1
|
addObserver: observer1
|
||||||
|
@ -44,6 +48,7 @@ int main ()
|
||||||
name: foo
|
name: foo
|
||||||
object: nil];
|
object: nil];
|
||||||
|
|
||||||
|
|
||||||
/* This will cause two messages to be printed, one for each request above. */
|
/* This will cause two messages to be printed, one for each request above. */
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
postNotificationName: foo
|
postNotificationName: foo
|
||||||
|
@ -54,5 +59,26 @@ int main ()
|
||||||
postNotificationName: foo
|
postNotificationName: foo
|
||||||
object: nil];
|
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);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue