Forum Navigation
You need to log in to create posts and topics.

NSRunAlertPanel function

Posted by: fblistserve <fblistserve@...>

On Jul 8, 2010, at 5:33 AM, Bernie wrote:

>
> Earlier examples of using Cocoa's NSAlert in FB required a C-wrapper function. The following code eliminates the need for FB's BeginC.....EndC by calling the Cocoa function NSRunAlertPanel (declared in AppKit.h). It works but has two bugs:
>
> [1] GCC 'incompatible pointer' warnings for the params.
> [2] Console gives NSAutoreleaseNoPool warning.
>
> Not a major improvement over previous versions. I'm more interested in knowing if there's an easy way to overcome the bugs. Anyone?

Seems more concise. I like it.

[2] I don’t know why those autorelease pool messages are showing up in the console but here is a thought. First, the message seems to indicate it needs an autorelease pool established and doesn’t have one to use. Obviously, we don’t have one in the code. Second, my recent Cocoa book reading implies some framework calls automatically add the object to the autorelease pool ( i.e. even though the programmer doesn’t doesn’t specify an autorelease message in the call ). Possibly this is the case with NSRunAlertPanel? Adding an autorelease pool after the NSApplicationLoad() and a pool release at the end eliminates console messages here.

[1] I don’t know the answer here but suspect it is related to passing CFStringRefs when it wants NSStrings. Since they are toll-free bridged it is only the compiler complaining ( i.e. I don’t think there is really a problem with running ). Need a way to appease the compiler.

Brian