Re: Bundle and window server interaction
Re: Bundle and window server interaction
- Subject: Re: Bundle and window server interaction
- From: Alastair Houghton <email@hidden>
- Date: Mon, 18 Jan 2010 15:02:54 +0000
On 18 Jan 2010, at 14:30, email@hidden wrote:
>> Quite possibly. Have you tried calling NSApplicationLoad() at the top of your main() function?
> Makes no difference as far as I can tell.
> There is a practical point here as I am trying to launch user interacting AppleScript from a foundation tool.
That's odd, because the following program works just fine (paste this into a Terminal window to try it):
----- Cut here -----
cd /tmp
cat > tst.m <<EOF
#include <Cocoa/Cocoa.h>
int main (void) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSApplicationLoad();
NSRunAlertPanel(@"Test", @"Testing", @"OK", nil, nil);
[pool release];
return 0;
}
EOF
gcc tst.m -framework Cocoa -o tst
./tst
--------------------
while omitting the NSApplicationLoad() causes it to fail with
<Error>: kCGErrorInvalidConnection: CGSGetCurrentCursorLocation: Invalid connection
<Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
You *definitely* need the NSApplicationLoad() (or a call to [NSApplication sharedApplication]) if you want a window server connection. I think, from trying it just now, that the problem is related to AppleScript rather than to the window server connection.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden