Skip to Main Content
Beginning iOS 4 Application Development
book

Beginning iOS 4 Application Development

by Wei-Meng Lee
October 2010
Beginner content levelBeginner
655 pages
14h 9m
English
Wrox
Content preview from Beginning iOS 4 Application Development

Appendix D. Crash Course in Objective-C

Objective-C is an object-oriented programming language used by Apple primarily for programming Mac OS X and iPhone/iPad applications. It is an extension to the standard ANSI C language and hence it should be an easy language to pick up if you are already familiar with the C programming language. This appendix assumes that you already have some background in C programming and focuses on the object-oriented aspects of the language. If you are coming from a Java or .NET background, many of the concepts should be familiar to you; you just have to understand the syntax of Objective-C and, in particular, pay attention to the section on memory management.

Objective-C source code files are contained in two types of files:

  • .h — header files

  • .m — implementation files

For the discussions that follow, assume that you have created a View-based Application project using Xcode and added an empty class named SomeClass to your project.

Directives

If you observe the content of the SomeClass.h file, you will notice that at the top of the file is an #import statement:

#import <Foundation/Foundation.h>

@interface SomeClass : NSObject {

}

@end

The #import statement is known as a preprocessor directive. In C and C++, you use the #include preprocessor directive to include a file's content with the current source. In Objective-C, you use the #import statement to do the same, except that the compiler ensures that the file is included at most only once. To import a header file ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning iOS 5 Application Development

Beginning iOS 5 Application Development

Wei-Meng Lee

Publisher Resources

ISBN: 9780470918029Purchase book