Re: Update Cocoa object from callback
Re: Update Cocoa object from callback
- Subject: Re: Update Cocoa object from callback
- From: Robert Grant <email@hidden>
- Date: Tue, 20 May 2003 18:47:57 -0400
Wasn't there kind of a big flame out a while ago about doing work in
these threads? I remember posting about using NSNotifications to alert
the main thread and there was a big discussion about how to ensure that
no memory was malloc'd and that the thread wasn't blocked/delayed etc.
So I'm surprised to see things like Autorelease pool allocations etc
(surely a malloc happens underneath) being recommended in the
callback....
Has the policy changed?
Thanks,
Robert.
On Tuesday, May 20, 2003, at 05:38 PM, Jeff Moore wrote:
Calling most of Cocoa's API requires doing so within a block guarded
by an autorelease pool. The threads that Cocoa owns itself will
arrange for this to be true. However, you are on your own when you are
executing code on threads not owned by Cocoa, like the CoreAudio
threads.
When I find myself in a situation where I need to call back into
Cocoa, I do one of two things. Either I explicitly create an
autorelease pool around the block of code in question or, more
usually, I make use of
-performSelectorOnMainThread:withObject:waitUntilDone: to be sure the
work I'm doing gets done on a known safe-for-Cocoa thread.
On Tuesday, May 20, 2003, at 02:15 PM, Mark's Studio wrote:
How do i notify my Cocoa object with a value from within the callback?
i tried with NSNotification
[[NSNotificationCenter defaultCenter] postNotificationName:@"Update"
object:[NSNumber numberWithUnsignedInt:myValue]]
but i get this in the console
_NSAutoreleaseNoPool(): Object 0x17f7ab0 of class NSCFNumber
autoreleased with no pool in place - just leaking
should i post notification with object:nil and then [myCocoaObject
setValue: myValue];
or what is the proper way to do this?
is AUListenerCreate something that can be used with Cocoa?
I looked at all the fine examples, but C++ is not my friend, so i did
not learn much from them.
Peter Mark
Mark's Recording Studio A/S
Lundeskovsvej 3 2900 Hellerup
Denmark
Tel: +45 35366078 Fax: +45 35366038
www.marks-studio.dk
email@hidden
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.
--
Jeff Moore
Core Audio
Apple
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.