title: Assigning to "id<Delegate>" from incompatible type Class __strong
body: <p>In the following code, delegating a method to <code>UIView</code> subclass.<br>
  But, the error <code>Assigning to "id&lt;Delegate&gt;" from imcompatible type Class __strong</code> occurs.</p>
  
  <p>How do I fix it to run <code>-delegateMethod</code>?</p>
  
  <p>ViewController.h</p>
  
  <pre><code>@protocol MyDelegate &lt;NSObject&gt;
  - (void)delegateMethod;
  @end
  
  @interface DetailViewController : UIViewController
  @property (nonatomic, assign) id&lt;MyDelegate&gt; delegate;
  @end
  </code></pre>
  
  <p>ViewController.m</p>
  
  <pre><code>- (void)viewDidLoad {
      CustomView *customView = [[CustomView alloc]init];
      self.delegate = customView; //Assigning to "id&lt;Delegate&gt;" from imcompatible type Class __strong
      [self.view addSubview:customView];
  }
  </code></pre>
  
  <p>CustomView.h</p>
  
  <pre><code>@interface CustomView : UIView
  </code></pre>
  
  <p>CustomView.m</p>
  
  <pre><code>@interface CustomView () &lt;MyDelegate&gt;
  
  - (void)delegateMethod {
      NSLog(@"succeeded");
  }
  </code></pre>
  
  <p>OtherViewController.m</p>
  
  <pre><code>@interface OtherViewController () &lt;MyDelegate&gt;
  
  - (void)aMethod {
      ViewController *vc = [[ViewController alloc]init];
      vc.delegate = self;
  }
  </code></pre>