title: iOS UIView inheritance bad performance
body: <p>I just wanted to do performances test on iOS on my project, and I am a little bit surprised of this behaviour : </p>
  
  <p>In a simple SingleView Application, if I add 1000 <code>UITextField</code> on rect (20, 20, 200, 200) from the <code>viewDidLoad</code>: main controller method, it works great. It's stupid, but it works.</p>
  
  <p>Now i create my class "<code>MyTextField</code>" inherited from <code>UITextField</code> and that implements drawRect: . The drawRect: implementation does nothing and i'm not overriding any other methods of <code>UITextField</code>. I replace my 1000 <code>UITextField</code> with <code>MyTextField</code> class, and surprise : it crashes. Worse, my iPhone reboots !</p>
  
  <p>I don't understand why. According to the Apple documentation, my drawRect does not need to call super. I also try to call <code>super drawRect:</code> but the result is the same. Reboot due to "<code>Receive memory warning</code>". </p>
  
  <p>Is there an explanation to this please ?</p>
  
  <p>EDIT : to be clear : </p>
  
  <p>It crashed (and my iPhone reboots) : </p>
  
  <pre><code>@implementation MyTextField
  
  -(void)drawRect:(CGRect)rect {
      [super drawRect:rect];
  }
  
  @end
  </code></pre>
  
  <p>It crashed too (and my iPhone reboots) : </p>
  
  <pre><code>@implementation MyTextField
  
  -(void)drawRect:(CGRect)rect {
      // or does nothing
  }
  
  @end
  </code></pre>
  
  <p>It works : </p>
  
  <pre><code>@implementation MyTextField
  
  @end
  </code></pre>
  
  <p>Here is my ViewController :</p>
  
  <pre><code>- (void)viewDidLoad {
      [super viewDidLoad];
  
      NSLog(@"######### START ###########");
      for (int i = 0 ; i &lt; 1000 ; i++) {
          MyTextField *tf = [[MyTextField alloc] initWithFrame:CGRectMake(20, 20, 200, 200)];
          [self.view addSubview:tf];
      }
      NSLog(@"######### END ###########");
  }
  </code></pre>
  
  <p>It does nothing else</p>