Re: Callbacks and autorelease pools
Re: Callbacks and autorelease pools
- Subject: Re: Callbacks and autorelease pools
- From: Nick Zitzmann <email@hidden>
- Date: Mon, 22 Sep 2003 12:57:07 -0700
On Monday, September 22, 2003, at 12:18 PM, Stefan Pantos wrote:
If there isn't then. The NSL library works using callback. I want to
add something to an NSArray in the callback. This means I need to use
a Obj-C wrapper. The wrapper needs allocating but it doesn't like the
NSArray because it has no autorelease pool being a call from NSL. How
do I fix/get round this?
At least this is what I think the error "2003-09-22 19:43:11.933
MyProgram[12932] *** _NSAutoreleaseNoPool(): Object 0x321260 of class
NeighborhoodWrap autoreleased with no pool in place - just leaking"
means.
It's really simple. In your callback, doing the following ought to work:
void callback(...)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// do your work here, then just before the function ends...
[pool release];
}
Nick Zitzmann
AIM/iChat: dragonsdontsleep
Check out my software page:
http://seiryu.home.comcast.net/
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my
telephone." - Bjarne Stroustrup
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.