How is the drawRect method being called

#1

Hi,

I could not understand how the drawRect method was being called in the program.

In BNRAppDelegate.m, only the firstView object is initialised and added to the subView.
This is the code:

[code] CGRect firstFrame = self.window.bounds;
BNRHypnosisView *firstView = [[BNRHypnosisView alloc]initWithFrame:firstFrame];

[self.window addSubview:firstView];[/code]

Shouldn’t there be an explicit call to the drawRect method like this:

Since there is no such call, who is calling this method and how is the code getting executed ?

#2

The drawRect: method is called by UIKit; you never call it directly.

To understand what’s going on, start reading (patiently) the following topics:

  • View Programming Guide for iOS
  • UIView Class Reference

[Become a competent programmer: pretty-function.org]

#3

Thanks.