title: objective-c protocol delegates
body: <p>I'm understanding how delegates work, had gone trough some examples, but now with a basic app for testing, it seems i haven't yet got it,</p>
  
  <p>here my code:</p>
  
  <p>Class defining protocol > *.h</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  @protocol protoPerra &lt;NSObject&gt;
  
  -(void) dimeTuNombre:(NSString *) s;
  @end
  
  @interface MyClassic : NSObject {
  id&lt;protoPerra&gt; _delegate;  
  }
  @property (assign) id&lt;protoPerra&gt; delegate;
  @end
  </code></pre>
  
  <p>Class implementing protocol> *.m</p>
  
  <blockquote>
    <p>#import "MyClassic.h"</p>
  </blockquote>
  
  <pre><code>@implementation MyClassic
  @synthesize delegate = _delegate;
  - (id)init
  {
  self = [super init];
  if (self) {
      // Initialization code here.
      [[self delegate] dimeTuNombre:@"pinguete"];
   }
  
  return self;
  }
  -(void) dealloc {
  [_delegate release];
  _delegate = nil;
  [super dealloc];
  }
  @end
  </code></pre>
  
  <p>Class Adopting protocol:</p>
  
  <blockquote>
    <p>#import "MyClassic.h"
     @interface MainViewController : UIViewController (protoPerra) </p>
  </blockquote>
  
  <p>.m</p>
  
  <blockquote>
  <pre><code>#import "MainViewController.h"
  </code></pre>
  </blockquote>
  
  <pre><code>  @implementation MainViewController
    -(void) dimeTuNombre {
     NSLog(@"ss9!! tkt");
     }
     - (void)viewDidLoad {
  [super viewDidLoad];
  
  UILabel *lava = [[[UILabel alloc] initWithFrame:CGRectMake(30, 100, 100, 20)] autorelease];
  lava.text = @"lava ss9";
  [self.view addSubview:lava];
  
  MyClassic *pirr = [[[MyClassic alloc] init ] autorelease];
  [pirr setDelegate:self];
   }
   -(void) dimeTuNombre:(NSString *)s {
     NSLog(@"%@",s);
    }
    @end
  </code></pre>
  
  <p>so what is missing in this simple example to make it work with my delegate?</p>
  
  <p>thanks a lot!</p>
  
  <p>Please note i have used () insted of the &lt;> [in the .h of the adopting class] as if i use the Chevrons, the code disappears </p>