title: How can I create my own methods which take a block as an argument and which I can call later?
body: <p>How can I create my own methods which take a block as an argument and which I can call later?</p>
  
  <p>I have tried following things.</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  typedef void (^viewCreator)(void);
  
  @interface blocks2ViewController : UIViewController
  {
  }
  -(void)createButtonUsingBlocks:(viewCreator *)block;
  
  @end
  
  
  - (void)viewDidLoad {
    [super viewDidLoad];
    [self createButtonUsingBlocks:^(NSString * name) {
          UIButton *dummyButton = [[UIButton alloc]initWithFrame:CGRectMake(50, 50, 200, 100)];
          dummyButton.backgroundColor = [UIColor greenColor];
          [self.view addSubview:dummyButton];
    }];
  }
  
  -(void)createButtonUsingBlocks:(viewCreator *)block
  {
      //    Do something
      NSLog(@"inside creator");
  }
  </code></pre>
  
  <p>I have also tried to pass the block variable to my custom method but without any success. Why it is so and what is the right way to do this?</p>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>This is file <code>is.h</code>:</p>
  
  <pre><code> #import &lt;UIKit/UIKit.h&gt;
  
  typedef void (^viewCreator)(void);
  
  @interface blocks2ViewController : UIViewController
  {
  
  }
  - (void)createButtonUsingBlocks:(viewCreator)block;
  @end
  </code></pre>
  
  <p>And this is the <code>.m</code> file:</p>
  
  <pre><code>#import "blocks2ViewController.h"
  
  @implementation blocks2ViewController
  // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
  - (void)viewDidLoad {
      [super viewDidLoad];
          [self createButtonUsingBlocks:^(NSString * name) {
          UIButton *dummyButton = [[UIButton alloc]initWithFrame:CGRectMake(50, 50, 200, 100)];
          dummyButton.backgroundColor = [UIColor greenColor];
          [self.view addSubview:dummyButton];
          [dummyButton release];
      }];
  }
  
  - (void)didReceiveMemoryWarning {
      // Releases the view if it doesn't have a superview.
      [super didReceiveMemoryWarning];
  
      // Release any cached data, images, etc that aren't in use.
  }
  
  - (void)viewDidUnload {
      // Release any retained subviews of the main view.
      // e.g. self.myOutlet = nil;
  }
  
  // ...
  
  -(void)createButtonUsingBlocks:(viewCreator)block
  {
  //    viewCreator;
      NSLog(@"inside creator");
  }
  @end
  </code></pre>