• 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: Bundle and window server interaction
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Bundle and window server interaction (From: "email@hidden" <email@hidden>)
 >Re: Bundle and window server interaction (From: Alastair Houghton <email@hidden>)

  • Prev by Date: Re: Bundle and window server interaction
  • Next by Date: CALayer with No Animation
  • Previous by thread: Re: Bundle and window server interaction
  • Next by thread: Re: Bundle and window server interaction
  • Index(es):
    • Date
    • Thread