Changes

An Overview of Objective-C Object Oriented Programming

415 bytes added, 19:26, 14 October 2009
Adding Instance Variables to a Class
== Adding Instance Variables to a Class ==
 
A key objective of object oriented programming is a concept referred to as ''data encapsulation''. The idea behind data encapsulation is that data should be stored within classes and accessed only through methods defined in that class. Data encapsulated in a class are referred to as ''instance variables''.
Instances of our BankAccount class will be required to store some data, specifically a bank account number and the balance currently held by the account. Instance variables are declared in the same way any other variables are declared in Objective-C. We can, therefore, add these variables as follows:
</pre>
Having defined our instance variables, we can now move on to defining the methods of the classthat will allow us to work with our instance variables while staying true to the data encapsulation model.
== Define Class Methods ==