kids encyclopedia robot

Objective-C facts for kids

Kids Encyclopedia Facts

Objective-C is an object-oriented programming language used to make computer programs for macOS and iOS devices.

History

Objective-C was created in the early 1980s by two programmers named Brad Cox and Tom Love. It didn't become popular, however, until it was bought by NeXT in 1988 for their NeXTSTEP operating system. After NeXT was bought by Apple in 1996, it became the main programming language for Mac OS X and later the iPhone, iPod touch and iPad.

Basics

Objective-C is a strict superset of C, meaning that any code that can be written in C can be used in Objective-C programs without being rewritten. However, it adds some features of its own that cannot be used in a traditional C program.

Messages

In Objective-C, functions are called using messages, a feature inspired by the SmallTalk programming language. Messages look like "blocks" of code similar to the on shown below:

[object messageToObject];

These blocks can be nested inside of each other as well, for example:

[[object messageToSendToObject] messageToSendToResultOfInnerMessage];

Interfaces and Implementations

Unlike other programming languages such as C and Java, Objective-C classes are divided into two separate parts:

  • Interface, which contains the initial declarations of variables and functions.
  • Implementation, which contains the actual code for functions.

Usually, these are put in two different files, with the interface using the ".h" extension and the implementation using the ".m" extension.

Variations

Objective-C has variants that add features to the original Objective C programming language.

Objective-C++

Objective-C++ allows for C++ code to be used in Objective-C applications.

Objective-C 2

Objective-C 2 is an improved version of Objective-C. It adds many features, such as garbage collection (automatic memory management), fast enumeration and properties (the automatic generation of variable methods).

See also

Kids robot.svg In Spanish: Objective-C para niños

kids search engine
Objective-C Facts for Kids. Kiddle Encyclopedia.