|
![](/i/fill.gif) |
gregjohn <pte### [at] yahoo com> wrote:
> My purpose here is to wrap my head around ObjC.
An object is an instantiation of a class. (In ObjC such an instantiation
is created by calling the 'alloc' method of such a class, and then calling
a constructor to initialize it.)
There are two things that make an object special and different from other
types of first-class citizens (such as ints): They (may) have methods (ie.
member functions), and the object you are handling might actually be of a
different (but usually inherited) type than what the actual code says.
In other words, if a function takes, for example, a parameter of type
MyClass*, then it may be called with an object that's actually not of
type MyClass but something else. (Usually it will be an object of a class
that has been derived from MyClass.)
You can then call the methods of that object (or, more technically speaking
in the context of Objective C, send a message to it). The method
implementations may be those that were implemented for MyClass, or they
might have been re-implemented in whatever derived class the object is.
(The thing is, this function doesn't need to know this in order to work.)
Since you are asking about Objective-C I'm assuming you are trying to
make an iPhone program (or at the very least a MacOS X one). Trying to
do so without understanding object-oriented programming can be a pretty
daunting task. It could take years to master.
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |