ExampleController.m

  1. #import "ExampleController.h"
  2. #import "FileToProcess.h"
  3.  
  4. @implementation ExampleController
  5.  
  6. /**
  7. * If your object is instantiated in a NIB file (Nextstep Interface Builder, IIRC),
  8. * this method will be one of the first called.
  9. */
  10. - (void)awakeFromNib {
  11. NSLog(@"Woke a %@ from nib", [self className]);
  12. }
  13.  
  14. - (NSString *)setTitle:(NSString *)newTitle {
  15. if (title == newTitle)
  16. return;
  17.  
  18. // One way to do this...
  19. [title release];
  20. title = [newTitle copy];
  21. /**
  22. * This will make sure changes to the newTitle var outside
  23. * of this method will not affect our title.
  24. */
  25.  
  26. // Another...
  27. [title release];
  28. title = [newTitle retain];
  29. /**
  30. * This means our title is now under control of whatever owns
  31. * the newTitle var. If the newTitle var is changed, then
  32. * so will our title, as we just hold a reference.
  33. */
  34. }
  35.  
  36. + (ExampleController *)controllerWithSomething:(id)something {
  37. return [[[ExampleController alloc] initWithSomething:something] autorelease];
  38. }
  39.  
  40. - (IBAction)processNow:(id)sender {
  41. [self doSomethingOnAClickEvent];
  42. }
  43.  
  44. @end
  45.