Moving from C to Objective-C

At first sight, Objective-C code is very similar to C code, with a few extra punctuation marks and symbols. But because Objective-C uses objects, you must think about app design in a different way.

To develop a C application, you organize your data and create functions to process the data. The mental model you use is close to that of real computer hardware. You design structures that hold data in memory and process them with instructions that run in a fixed order.

To develop an Objective-C application, you pick objects from the iOS “kit of parts,” customize them as needed, and link them by adding code to send messages. Events no longer happen in a fixed sequence, because Objective-C code is event-driven. App design focuses more on behaviors and less on data management, although you still have to include some of the latter in your app.

caution_exclamation_2c.eps

Some online descriptions of Objective-C bury you in jargon, with words like “polymorphism,” “dynamic typing,” and “dynamic binding.” These are complicated words for simple ideas. But they’re not often explained clearly, and you don’t need to know what they mean to use Objective-C successfully.

note_2c.eps

Many of the frameworks in iOS include both C and Objective-C features. It’s not unusual to find helper functions and basic ...

Get iOS App Development Portable Genius now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.