Changes

Jump to: navigation, search
Declaring, Initializing and Releasing a Class Instance
BankAccount *account1 = [[BankAccount alloc] init];
</pre>
<google>ADSDAQBOX_FLOW</google>
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 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. Some implementations of Objective-C also have a garbage collector but it is not implemented on all platforms (the iPhone being a case in point) so you should get into the practice of releasing allocated memory yourself:
[account1 release];

Navigation menu