background image
converter = [[Converter alloc]init];
This line allocates space in memory for a
Converter
instance and should be deallocated after you use it.
You may notice that you didn't deallocate this instance.
The reason you can do this is because Objective-C 2.0 utilizes garbage collection. To enable garbage collection:
1.
Choose Project > Edit Project Settings
2.
Navigate to the Build tab
3.
Set the value for Objective-C Garbage Collection to
Supported
under GCC 4.0 - Code Generation.
By supporting garbage collection, you don't have to worry about deallocating objects you instantiate. You
can leave your code just the way it is and not have to worry about memory leaks.
More information about garbage collection can be found in GNU C/C++/Objective-C 4.0.1 Compiler User Guide.
What's Next?
You've now completed the implementation of Currency Converter. Notice how little code you had to write,
given that your application now has a fully functional currency-converting system and a beautiful user
interface. In the next chapter, you will learn how to build and run the application.
What's Next?
51
2007-10-31 | © 2007 Apple Inc. All Rights Reserved.
CHAPTER 5
Bridging the Model and View: The Controller