• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Update Cocoa object from callback
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Update Cocoa object from callback


  • Subject: Re: Update Cocoa object from callback
  • From: Jeff Moore <email@hidden>
  • Date: Tue, 20 May 2003 14:38:35 -0700

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.

  • Follow-Ups:
    • Re: Update Cocoa object from callback
      • From: Brian Willoughby <email@hidden>
    • Re: Update Cocoa object from callback
      • From: Robert Grant <email@hidden>
References: 
 >Update Cocoa object from callback (From: "Mark's Studio" <email@hidden>)

  • Prev by Date: Re: Update Cocoa object from callback
  • Next by Date: Re: XML format for .mid files. Where's the spec?
  • Previous by thread: Re: Update Cocoa object from callback
  • Next by thread: Re: Update Cocoa object from callback
  • Index(es):
    • Date
    • Thread