Objetive C

Páginas: 3 (669 palabras) Publicado: 29 de agosto de 2011
Objective C Primer: Part 1 – Introduction to Objects - Learning iPhone Development

17/08/11 23:48

Learning iPhone Development
The key feature of Objective C (as compared to C) is that it is anobject-oriented language.

Objects
Consider a car. Every car has certain properties (it is blue, it has two wheels, it is located at your house) and can perform certain actions (it can driveforward, it can drive backward, it can turn). This combination of properties and actions are what defines a car . An object oriented language thinks about things similarly to the way you think about a car.It defines a class of objects (like cars), expects these objects to have certain properties, and expects these objects to be able to do certain things (and have other things done to them). In otherwords, while a language like C might understand the concept of “driving forward”, it has no idea what a car is, and no idea that only cars can drive forward. By contrast, an object oriented languageknows all about these relationships, and allows you to assume them in your code. So how does it work? Using Objective C you define a “class” of objects by specifying the properties of an object (alsoreferred to as “fields” or “instance variables”) and the actions that object can take (also referred to as methods). So lets consider our car. Assuming that all cars have a color, a certain number ofwheels, and can drive forward and backwards, we would create the following class definition:
1@interface Car : NSObject 2{ 3NSString *color; 4int wheels; 5} 6-(void) DriveForward: (int)feet; 7-(void)DriveBack: (int) feet; 8@end

Although we will discuss exactly how this works in the next lesson, what we have
http://www.optictheory.com/iphone-dev/2010/02/objective-c-for-c-programmers-part-1/Página 1 de 2

Objective C Primer: Part 1 – Introduction to Objects - Learning iPhone Development

17/08/11 23:48

done is specified the fields and methods each car has and can perform, though...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Objetive c
  • Desarrollo iOS- Objetive-C
  • El objetivismo
  • Objetivismo
  • Objetivismo
  • OBJETIVISMO
  • objetivismo
  • El objetivismo

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS