Changes

An Overview of Objective-C Object Oriented Programming

620 bytes added, 20:24, 13 October 2009
Declaring, Initializing and Releasing a Class instance
<pre>
BankAccount *account1 = [[BankAccount alloc] init];
</pre>
 
In the first step of this section we allocated memory for the creation of the class instance. Good programming conventions dictate that memory allocated to a class instance should be released when the instance is no longer required. Failure to do so can result in memory leaks and such that the application will continue to use up system memory until none is left. Those familiar with Java will be used to relying on the ''garbage collector'' to free up unused memory automatically. Objective-C has no such luxury and the memory allocated to a class instance must be manually released:
 
<pre>
[account1 release]
</pre>