Objective-C Programming

PDF version of this report
You must have Adobe Acrobat reader to view, save, or print PDF files. The reader
is available for free

Objective-C Programming

by Lynn

Docid: 00021342

Publication Date: 1712

Report Type: TUTORIAL


Objective-C was the primary development language for Apple products.
Given the popularity of the iPhone and iPad, app developers for the platform are
a hot commodity. This makes Objective-C an important language for anyone hoping
to tap into this large and potentially lucrative market or for any company
planning a mobile app to promote its goods or services. However, be aware that
Apple is replacing Objective-C with its Swift language so, although
Objective-C remains a key tool for developers, its days are numbered.

Report Contents::

Executive Summary

[return to top of this report]

Objective-C was the primary development language for Apple products.
Given the popularity of the iPhone and iPad, app developers for the platform are
a hot commodity. This makes Objective-C an important language for anyone hoping
to tap into this large and potentially lucrative market, or for any company
planning a mobile app to promote its goods or services. However, be aware that
Apple is to replacing Objective-C with its Swift language so, although
Objective-C remains a key tool for developers, its days are numbered.

Faulkner Reports
Flash Development Tutorial


[return to top of this report]

Objective-C is a set of extensions to ANSI C and is the main programming
language for Mac OS X and iOS development. The extensions are in large part
based on Smalltalk and provide object-oriented functionality to C.

The language came into being in the 1980s. It was adopted by the Free
Software Foundation and released under the GNU Public License (GPL). After
Steve Jobs was ousted from Apple and founded NeXT, he licensed Objective-C
for use in the development of the company’s operating system, NeXTstep.

During the 1990s, Apple was struggling and decided as part of its
recovery plan to replace the old MAC OS. Rather than building its own
operating system, it decided to purchase a company that already had a viable
OS. That company was NeXT. Steve Jobs returned to Apple, NeXTstep became the
foundation of Mac OS X, and later iOS, and Objective-C became
the development system of choice for Mac and iPhone. It is now the
nineteenth most popular programming language, according to the TIOBE
index (which uses the number of skilled engineers, courses, and third-party
vendors found through major search engines to calculate its ratings), thanks mainly to the popularity of the iPhone and iPad.
Swift is number twenty.

Current View

[return to top of this report]

Objective-C is one language portion of the Apple development environment. Its
application framework, a collection of Objective-C
classes that enable rapid development of applications, is known as Cocoa.

Objective-C’s syntax is similar
to that of C but with some important differences. C is not an object-oriented
language, so the syntax for object components are derived from Smalltalk. Rather than
calling methods as one would do in C, the programmer passes messages to object instances.

This leads to some challenges. GNUstep blogger Adam Fedor notes, "Since
Objective-C doesn’t try to improve the C language, you have to deal with all
the faults and caveats of C. In addition, the philosophy of Objective-C is to allow for a great deal
of flexibility, leaving the programmer to watch out for potential problems
rather than forcing various restrictions. For instance, Objective-C provides
an object definition that is completely untyped. This is the id
variable type, which stands for any object. With this type, you can send a
message to any object, without knowing at all what the object is or what it
can do. Like C, this flexibility allows you to perform great tricks, while
forcing the programmer to introduce his own conventions to prevent errors."1

Yet, Apple says, programmers can adapt the C language software they’ve
already written and compile C code with its Objective-C compiler. Unlike
C, however, Objective-C needs a runtime environment since it performs much of its
activity dynamically at runtime rather than at compile and link time.

are two versions of the Apple Objective-C runtime: modern and legacy.
The major difference between them is that certain code changes that used to
require a recompile under the legacy system no longer do so under the modern
runtime. iPhone applications and 64-bit programs on OS X v10.5 and later use
the modern version of the runtime. Other programs (32-bit programs on OS X
desktop, for example) use the legacy version of the runtime.

Objective-C adds the following features, as enumerated in Apple’s
documentation, to standard C:

  • Objects, classes, and messaging

  • Protocols
  • Declared properties
  • Categories and extensions
  • Associative references
  • Fast enumeration
  • Enabling static behavior
  • Selectors
  • Exception handling
  • Threading

Since Objective-C is just a thin layer
on top of standard C, which doesn’t have classes, it does not make
everything an object. It also has the usual set of primitives:

  • Int – integers
  • Float – floating point numbers
  • double – double precision floating point
  • char – single character
  • [] array – int values
  • BOOL – Yes/No

Predefined objects such as NSObject are provided to take care of low
level system tasks; most objects constructed by developers inherit from
NSObject. The predefined object names all start with "NS", for NextStep,
reflecting their origin. The community has settled on naming conventions for
classes and variables as well: Classes use camelcase (the first letter of
each word is capitalized, for example, AddPerson), and variables
are camelcase, but with the first letter of the variable name in lower case
(eg: familyMember). Underscores are typically not used. To avoid
naming conflicts, a three letter prefix is used on class names (Apple has
reserved all of the two letter prefixes for its own use); developers often use
their initials or their company’s initials.

The Xcode IDE is Apple’s complete developer toolset used to create
applications for Mac, iPhone, and iPad, Apple
Watch and Apple TV. It bundles the Instruments analysis
tool, iOS Simulator, and OS frameworks in the form of iOS SDKs and OS X
SDKs. Xcode creates skeleton versions of the files needed to build a
command-line based Objective-C application; Objective-C source files are
identified by the .m filename extension. The current version, Xcode
contains extensions to Objective-C that make it easier to program. It also
supports development for the Swift 3
and 4 programming

Enhancements to Xcode 9 include:

  • VR support
  • A new editor
  • Refactoring
  • Network debugging for iOS and tvOS devices
  • GPU frame capture
  • Undefined behavior sanitizer

Enhancements to Xcode 8 include:

  • Version editor
  • Source control
  • Test-driven development features
  • Code snippets
  • Tabs

Ehhancements to Xcode 7.1 include:

  • New playground features including markup in comments and inline results
  • UI testing and code coverage
  • Metal support
  • Improved SpriteKit and SceneKit editors
  • Debugging workflows
  • Energy gauge for iOS
  • Address sanitizer

Enhancements to Xcode 6.1 include:

  • Live rendering
  • View debugging
  • Performance testing
  • Storyboards for OS X
  • Extensions and frameworks for iOS
  • Game building tools

Enhancements to Xcode 5 include:

  • Automatic configuration: Xcode 5 automatically
    configures your app to enable Apple services such as iCloud, Passbook,
    or Game Center, directly within the IDE.
  • Test navigator: Test Navigator helps you create,
    edit, and run your unit tests.
  • Bots for continuous integration: Xcode 5 works
    closely with OS X Server for OS X Mavericks to easily create bots that
    continuously build your app, execute your complete test suite, and run
    the Xcode static analyzer to find potential bugs.
  • Enhanced Auto Layout: Allows you to create a single
    user interface which automatically adjusts to screen size, orientation,
    and localization.
  • Asset management: Asset Catalogs, labeled as
    .xcassets in Xcode 5, make managing your images much simpler.
  • Debug Gauges: New debug gauges in Xcode 5 show
    resource consumption data at a glance, including CPU, memory, energy
    use, iCloud, and OpenGL ES.
  • Enhanced Visual Debugger: Built on the powerful
    LLDB debugging engine, the Xcode visual debugger in Xcode 5 is cleaner
    and more readable, and the Data Tips that hover over your code are more
  • Source Control: The new top-level Source Control
    menu always shows the currently active branch of the project you are
    working on, and gives you quick access to switch, create, and merge

Enhancements to Xcode 4.5 included:

  • LLDB is the default debugger

  • LLDB supports hardware watchpoints on iOS devices
  • OpenGL debugging and performance analysis for iOS apps is integrated into
  • Auto Layout is supported for iOS 6

Xcode 4.5 also extends new features released in Xcode 4.4 as listed

  • Improved localization workflow using base language .xib
    files now supports OS X 10.8 in addition to iOS Storyboards
  • Objective-C literals in NSArray and NSDictionary
    classes are supported for iOS 6.0
  • Support for subscripting using '[ ]' syntax with Objective-C
    container objects are supported for iOS 6.0
  • Compatibility with the C++11 standard is improved with added support for
    lambda expressions

The current Objective-C compiler provides memory management
(known as Automatic Reference Counting, or ARC), absolving
the developer of that responsibility. ARC is automatically
inplemented at compile time.

In the Windows environment, programmers need to obtain the GNUstep
environment, using a toolkit called MinGW. MinGW is an abbreviation of
Minimal GNU for Windows
and essentially provides a port of the GNU
compiler collection, including Objective-C support, and a minimal shell
environment for Windows platforms. Installation of GNUstep involves
installing both MinGW and GNUstep. To build apps using
iOS APIs that run in the Windows environment, developers can download the
open source WinBridge for iOS from GitHub, which provides an Objective-C
development environment in Visual Studio.


[return to top of this report]

Objective-C has been a language of choice for mobile developers targeting the immense
iOS market. However, it is not
the only option for the platform. HTML5 is gaining traction and, along with CSS3,
is another good tool to add to a developer’s arsenal.

Since Objective-C is
based on an open source project that originated at the University of
Illinois, it has a vibrant development community working to extend and
enhance it. Apple and others
continue to develop new capabilities in the language (although things are
changing, as you will see), and have been working
to streamline development tasks. In April 2012, for example, three new
were introduced: NSNumber Literals that provide a syntax for creating
them from scalar literal expressions, Collection Literals that provide a
shorthand for creating arrays and dictionaries, and Object Subscripting that
lets developers use subscripts with Objective-C objects. They became available
to developers using the Apple LLVM compiler 4.0, and users of the clang 3.1 open
source version. Current version is LLVM

To further complicate matters, Apple announced at its 2014 Worldwide
Developers Conference that Objective-C will be replaced by a new programming
language, Swift, which it refers to as "Objective-C without the C". However,
given the sheer number of apps written in Objective-C, it is unlikely that the
language will disappear quickly. Swift uses the Objective-C
runtime and the two languages are designed to co-exist.

However, Objective-C
has plummeted on the TIOBE Programming Community index, an indicator of the
popularity of programming languages, now only number 19,
one step above Swift at 20 (a year
ago they were 10 and 12 respectively), after having risen to number 3. This suggests that its demise may be sooner
than originally thought.


[return to top of this report]

C programmers who wish to develop for the iOS platform are in an excellent
position. Although Objective-C has a number of additional features and is
object-oriented rather than procedural, its roots are in C, and Apple and others provide a good amount of documentation for the language and
framework components.

Developers should be aware that the language and platform have evolved,
and programming apps for newer versions of iOS may involve different syntax
than that for older versions. Xcode offers a "Convert to modern Objective-C
syntax" command to compensate.

While the design changes between procedural and object-oriented languages
may be confusing at first, grasping them is a good investment for any
programmer since object-oriented programming is the foundation of most
modern code development in any language.

With the ever growing adoption of both iPhone and iPad and market pressure
toward mobile apps, Objective-C skills are a valuable addition to the toolkit
of any developer who plans to maintain existing iOS apps; as Apple puts its
support behind Swift, Objective-C is becoming less and less attractive for
new development.


1Fedor, Adam. “Objective-C Is Fun."

[return to top of this report]

About the Author

[return to top of this report]

Lynn Greiner is Vice President, Technical
Services for a division of a multi-national corporation, and also an
award-winning computer industry journalist. Ms. Greiner is a regular contributor
to Faulkner Information Services and a member of the Advisor Panel.

[return to top of this report]