On 18 Jan 2010, at 14:30, [email protected] 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 protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]