Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
1. | Implement a copy method for the AddressBook class according to the NSCopying protocol. Would it make sense to also implement a mutableCopy method? Why or why not? |
2. | Modify the Rectangle and XYPoint classes defined in Chapter 8 to conform to the <NSCopying> protocol. Add a copyWithZone: method to both classes. Make sure that the Rectangle copies its XYPoint member origin using the XYPoint’s copy method. Does it make sense to implement both mutable and immutable copies for these classes? Explain. |
3. | Create an NSDictionary dictionary object and fill it with some key/object pairs. Then make both mutable and immutable copies. Are these deep copies or shallow copies that are made? Verify your answer. |
4. | Who is responsible for releasing the memory allocated for the new AddressCard in the copyWithZone: method as implemented in this chapter? Why? |