SDK's programming is done in Objective-C, a full superset of C, allowing you to write any traditional C code. It adds powerful object-oriented capabilities as well. These extensions come by way of the design philosophies of Smalltalk, one of the earliest object-oriented languages. Because of its origin beyond the standard boundaries of C, Objective-C's messaging code may look a little strange to you at first; but after you get the hang of it, you'll discover that it's elegant and easy to read, providing some nice improvements over traditional ANSI C code. We look at Objective-C's messages, class definitions, properties, compiler directives, categories, and protocols. Although this overview gives you enough to get started with Objective-C, it can't provide all the details, particularly for more complex functionality like properties and categories.
As implemented by Apple and used throughout the iPhone OS's frameworks, Objective-C is built entirely around objects. Windows, views, buttons, sliders, and controllers all exchange information with each other, respond to events, and pass actions in order to make your program run. A header (.h) file and a source code (.m) file together represent each object in Objective-C. Sometimes you'll access standard classes of objects that come built into the iPhone OS frameworks, but often you'll instead subclass objects so that you can create new behaviors. When you do this, you'll add a new header and source code file to your project that together represent the new subclass you've invented. Although we won't dwell on it much, note that C++ code can be mixed in with Objective-C code. We leave the specifics of that for the experienced object-oriented programmer. You can also freely insert older C syntax.
Objective-C's most important extension to the C programming language is the message. A message is sent when one object asks another to perform a specific action; it's Objective-C's equivalent to the procedural functional call. Messages are also the place in which Objective-C's syntax varies the most from ANSI C standards - which means that when you understand them, you'll be able to read most Objective-C code. There are three ways in which this message could be slightly more complex. First, it could accept arguments; second, it could be nested; and third, it could be a call to one of a few different recipients.
Each class tends to be represented by a matched pair of files: a header file and a source code file. To define a class, each of these files must contain a special compiler directive, which is always marked in Objective-C with an @ symbol. First, you define the interface for the class, which is a simple declaration of its public variables and methods. You do this in the header (.h) file. Next, you define the implementation for the class, which is the content of all its methods; this is done in a source (.m) file.
Our website is not responsible for the information contained by this article. Articleinput.com is a free articles resource thus practically any visitor can submit an article. However if you notice any copyrighted material, please contact us and we will remove the article(s) in discussion right away.
Note: This article was sent to us by: Marvin V. Hayels at 09232010
1. Why is Linux such an incredible piece of sowtware
All articles are property of their respective authors. Please read our Privacy Policy!
© 2009 ArticleInput.com.
Partners: Damenmode