• 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: Can I Send Apple Events in Cocoa?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can I Send Apple Events in Cocoa?


  • Subject: Re: Can I Send Apple Events in Cocoa?
  • From: Ricky Sharp <email@hidden>
  • Date: Sun, 11 Dec 2005 14:37:41 -0600


On Dec 11, 2005, at 2:02 PM, Kaydell Leavitt wrote:

Can I call the following Carbon C++ function from the
app that is thusfar written in Cocoa and Objective C?
I have to use Apple Events because that's what's
available to me.

Thanks.

Kaydell

OSStatus SendRoutineMaintenanceAE(FSSpec fileSpec) {
// --- declare local variables --- //
OSStatus status;
AppleEvent theAEvent, theReply;
AEAddressDesc inventoryAddress;
OSType inventoryCreator = kInventorySignature;
long index;
// --- set up locals --- //
AECreateDesc(typeNull, NULL, 0, &theAEvent);
AECreateDesc(typeNull, NULL, 0, &inventoryAddress);
AECreateDesc(typeNull, NULL, 0, &theReply);
// --- create an Do Routine Web Maint. event
targeting the Inventory Client app --- //
status = AECreateDesc(typeApplSignature,
&inventoryCreator, sizeof(inventoryCreator),
&inventoryAddress);
if (noErr == status)
status = AECreateAppleEvent(kInventoryAnalyzerClass,
kRoutineWebMaintenance, &inventoryAddress,
kAutoGenerateReturnID, kAnyTransactionID, &theAEvent);
// --- send the event to the POSIM Inventory Client
--- //
if (noErr == status)
status = AESend(&theAEvent, &theReply, kAEWaitReply,
kAENormalPriority, kAEDefaultTimeout, NULL, NULL);
// --- clean up and leave --- //
AEDisposeDesc(&theAEvent);
AEDisposeDesc(&inventoryAddress);
AEDisposeDesc(&theReply);
// --- return the status --- //
return status;
}

This is all just C, so drop it in as-is to your existing codebase and just call it. Remember that Obj-C is a superset of C. Also remember to link against the Carbon framework to gain access to those APIs.

Note that you can also incorporate C++ code; search the docs/archives for examples if needed.
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: Can I Send Apple Events in Cocoa?
      • From: Daniel Jalkut <email@hidden>
References: 
 >Re: Can I Send Apple Events in Cocoa? (From: Kaydell Leavitt <email@hidden>)

  • Prev by Date: Re: troubles with a progress bar updating
  • Next by Date: Re: Can I Send Apple Events in Cocoa?
  • Previous by thread: Re: Can I Send Apple Events in Cocoa?
  • Next by thread: Re: Can I Send Apple Events in Cocoa?
  • Index(es):
    • Date
    • Thread