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?
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).
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.
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:
- Write your classes
- Create a Shared Library project
- Build the library and distribute it
For the iter-process communication and embedding parts of COM, there isn't anything standardized, really.
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.
Maybe CFPlugin.
From Apple :
The Core Foundation framework object CFPlugin implements a small
subset of the Microsoft Component Object Model (COM) standard. COM
allows you to instantiate C functions and data in an object-oriented
manner at runtime.
It is initially devoted to a plugin architecture but it seems that it can be used as a COM equivalent, see this old post and Chapter 5 (Carbon Plug-ins) of "Mac OS X Advanced Development Techniques " by Joe Zobkiw . Unfortunately I could not find more examples.