tags:

views:

174

answers:

5

I'm new to the world of Mac programming. Can someone please tell me what the equivalent of reusable COM components are in Mac and some links to a good resource to get started (in creating reusable COM-like components and referring those components from a calling app)? Thank you.

Clarification:
- I wish to know if there exist a similar technology, which is supported at OS level.
- I asked the question because I want to port some of my apps (which make use of existing type libraries from Windows as well as those that I make) to Mac.
- Is it possible that I create wrapper classes for my existing (Window) type libraries and refer to them from a Mac app?

+2  A: 

Well, there's XPCOM.

Tim Sylvester
XPCOM is a mozilla thing. Unless you're building browser plug-ins it isn't really relevant.
jeffamaphone
One can use XPCOM outside Mozilla, and on binary level it's really mostly just COM (same vtable layout, same base interfaces...). But of course it's not universal, so it can only be used to communicate between two applications that specifically agree on using it.
Pavel Minaev
+3  A: 

Cocoa/Objective-C objects are pretty much all you need. At a higher level, NIBs can be reusable between applications, although I don't think that is widely done.

You can write plug-ins for Interface Builder to use your own components like the standard ones.

Apple Events and AppleScript are the standard IPC and scripting technologies.

However, unlike COM in the Windows world, there are really no standard conventions for components that interact with one another via standard interfaces, live in standard containers, participate in transactions, etc. There is no analogue to a type library or IDL (although a scripting dictionary may come close).

Kristopher Johnson
+3  A: 

There's nothing quite like COM in Mac OS X (I assume you're talking about OS X, not classic Mac OS). If you want to write reusable components or Cocoa applications, it really is just about as simple as:

  1. Write your classes
  2. Create a Shared Library project
  3. Build the library and distribute it

For the iter-process communication and embedding parts of COM, there isn't anything standardized, really.

Mark Bessey
For IPC, OS X has Apple Events/AppleScript and Portable Distributed Objects. Those have been pretty standard for going on two decades now.
Chuck
This sounds more like a DLL equivalent than COM.
Will Eddins
@Will -- Well, in a way, what is COM but DLLs + a system for objects and interfaces? In Mac OS, .dylib provides the former and the objC runtime provides the latter.
asveikau
Chuck, while I don't disagree that AppleEvents and PDO *exist* they're not an exact replacement for COM IPC. You could implement an interface enumeration system on PDO, but it doesn't really provide anything out of the box. And there isn't anything (to the best of my knowledge) that provides an equivalent to a COM Container. Lots of Cocoa apps provide an interface for loadable bundles, but again, there's no enumeration of capabilities (unless the app developer specifies one), and so you can't do tricks like embedding a generic component into multiple apps.
Mark Bessey
+3  A: 

I think that Getting Started with Interapplication Communication from the Mac Dev Center would be a good place to start. There is no direct equivalent to COM/OLE as far as I can tell across the entire OS, but XPCOM and CORBA can be used for some scenarios.

Distributed Objects Programming Topics is probably the best place to look for conventional Mac solutions to getting apps to talk to each other.

JasonTrue
+1  A: 

You might want to check out Mono. Although it won't let you directly reuse your existing Windows-specific COM code, it does give you a similar paradigm of reusable components across different programming languages (any that have a CLI compiler), and even different operating systems (e.g., Windows, Mac, Linux).

I would also recommend CocoaSharp for wiring up directly to the native Mac OS X libraries.

Kurt