Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. @property(copy) NSString* name
  2.  
  3. [greeter setName:@"Jane"];
  4.  
  5. -(void)dealloc{
  6. [super dealloc];
  7. }
  8.  
  9. //
  10. // Greeter.h
  11. // Flashlight2
  12. //
  13.  
  14. #import <Foundation/Foundation.h>
  15.  
  16. @interface Greeter : NSObject
  17.  
  18. @property(copy) NSString* name;
  19.  
  20. -(NSString*)description;
  21. -(void)dealloc;
  22.  
  23.  
  24. @end
  25.  
  26. //
  27. // Greeter.m
  28. // Flashlight2
  29. //
  30.  
  31. #import "Greeter.h"
  32.  
  33. @implementation Greeter
  34.  
  35.  
  36. -(NSString*)description {
  37. NSString* msg = [[NSString alloc] initWithString:@"I am a Greeter"];
  38. return [msg autorelease];
  39. }
  40.  
  41. -(void)dealloc{
  42. [super dealloc];
  43. }
  44.  
  45. @end
  46.  
  47. @implementation AppDelegate
  48.  
  49.  
  50. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  51.  
  52. // Override point for customization after application launch.
  53.  
  54. Greeter* greeter = [[Greeter alloc] init];
  55. [greeter setName:@"Jane"]; //constant string in memory for life of program
  56.  
  57. NSLog(@"%@", greeter);
  58. [greeter release];
  59.  
  60.  
  61. return YES;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement