Readings
Assignments
- Read the class tutorial on Objective-C. Use it as a starting point. Define a new class in the same file called YourClass. Define one method (besides init/dealloc) called goodbye that takes no parameters and returns NSString*. In this method call return an NSString with the contents “Goodbye, nice seeing you!”. Check and make sure that this works.
- Add an instance variable friend of type YourClass* to the MyClass interface for storing a reference to an instance of your newly defined class. Create a setter and getter for this variable- add setFriend/friend methods to the MyClass implementation. setFriend returns void and receives an argument of type YourClass*. setFriend should release anything that was previously stored in the instance variable friend, and retain the argument passed in. The friend method takes nothing and returns a value of type YourClass*
- In main allocate an instance of YourClass and set it as the friend the MyClass instance. The following NSLog statements should be in your code and work.
NSLog(@"This is my friend %@ and he says '%@'", [instance friend], [[instance friend] goodbye]);
- Send me a zip of your program.