Code Reuse in Objective C

One of the trivial ways to enable code reuse in traditional programming platforms like C++, C# or VB is building dynamic libraries that are compiled binaries that can be shared with different consumers who can embed these libraries into their application’s code and derive use out of them. These dynamic libraries (or DLLs) are linked with their host’s code at run-time.

The ability to use/link dynamic libraries is missing in Apple’s Objective C platform for whatever reason. The alternative that the platform gives us (that I put to use recently) is building static libraries. Interestingly, this is probably the only way to enable code sharing/reuse in Objective C. This thing was pretty new to me having been used to the dynamic way for a long time.  Xcode makes building static libraries a piece of cake. It is even possible to develop a library that would contain UI components (like Cocoa-touch views/controllers etc) and have an application make use of these components via the shared static library.

This article goes over the process of developing a simple static library in Objective C using Xcode.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s