kids encyclopedia robot

Objective-C facts for kids

Kids Encyclopedia Facts

Objective-C is a special programming language that helps people create computer programs. It's mostly used for making apps and software for Apple devices like Mac computers and iPhones, iPods, and iPads.

History of Objective-C

Objective-C was invented a long time ago, in the early 1980s. Two smart programmers, Brad Cox and Tom Love, created it. It became much more famous when a company called NeXT bought it in 1988. NeXT used it for their special computer system, NEXTSTEP.

Later, in 1996, Apple bought NeXT. This made Objective-C the main language for Apple's computers (Mac OS X). It was also used for popular devices like the iPhone, iPod touch, and iPad.

How Objective-C Works

Objective-C is built on top of another programming language called C. This means that any code written in C can also be used in Objective-C programs. You don't need to change it! However, Objective-C also has its own special features that C doesn't have.

Sending Messages in Code

In Objective-C, you tell parts of your program what to do by sending them "messages." This idea came from another language called SmallTalk. Messages look like small blocks of code.

Here is an example of what a message looks like:

[object messageToObject];

You can even put messages inside other messages. This helps you do more complex things.

Look at this example:

[[object messageToSendToObject] messageToSendToResultOfInnerMessage];

Interfaces and Implementations

Unlike some other programming languages, Objective-C divides its "classes" into two main parts. A class is like a blueprint for creating objects in your program.

  • Interface: This part tells you what a class can do. It lists all the variables and functions (actions) that the class will have.
  • Implementation: This part contains the actual code that makes the functions work. It's where you write the instructions for what each function does.

Usually, these two parts are kept in separate files. The interface file often ends with ".h" (like "MyClass.h"). The implementation file ends with ".m" (like "MyClass.m").

Different Versions of Objective-C

Objective-C has some different versions that add new features.

Objective-C++

Objective-C++ lets programmers use code from another language called C++ inside their Objective-C programs. This gives them more tools to work with.

Objective-C 2

Objective-C 2 is an improved version of the original Objective-C. It added many helpful features. One big feature is "garbage collection," which automatically manages memory for your program. This makes it easier for programmers to write code without worrying about memory issues.

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