Presentation on theme: "Lecture 2 - Introduction Objective C is used primarily for application development on Apple's Mac OS X and iPhone. On the Apple it is used together with."— Presentation transcript:
Lecture 2 - Introduction Objective C is used primarily for application development on Apple's Mac OS X and iPhone. On the Apple it is used together with Cocoa (NS class library) and on the iPhone together with the UI class library. It is an Object Oriented language, that provides for classes, derivation, and runtime binding. It is provided with two extensive class libraries: Cocoa and UI, and is a strict superset of C. One can freely include C code within an Objective-C class. It can be compiled with the gcc compiler on the Mac. This course teaches in detail the syntax and features of the language, supported by many programming examples, drill quizzes and homework. It will use the Cocoa API to develop example applications for the Mac with a graphical interface. The introduction will start with development of OC programs on the command line. Later the X-code IDE will be used for development.
Objective C - Lecture 2 Runtime Classes Objects Messaging
Runtime Objective C needs a compiler, like the C language, and also a runtime system which executes the compiled code. It creates objects, sends messages, allocates and frees memory, etc. We dont need to know much about the runtime system. More about this in the Objective-C 2.0 Runtime Programming guide
Classes Classes are blueprints for objects, like layouts or plans. They specify the data the object possesses and the operations the object can perform on these data. When a message is sent to an object, the operation with this name is performed by the object using the objects data and the messages parameters.
Objects Objects are created at runtime and have only a limited life span. An object associates data with operations that can be performed on these data (methods). We will work a lot with objects during this course.
Messaging Objects are sent messages during the running of the program. The object that receives the message is called the receiver. The receiver is determined only at runtime. When it receives a message the object will execute a particular method. Objective C follows a special syntax for sending messages.
Running programs Running OC programs on the command line. Small programs have interface and implementation together in the same file. The file has a.m extension Compile with the gcc compiler, an a.out file will be produced Run a.out as a Unix command
Running programs The command for running an OC program on the command line is: gcc prog.m -L /System/Library/Frameworks/Foundation.fra mework/Foundation