Can any body explain me what is a Context and how can i use it? There is also Graphics Context (CGContextRef).Is there any relation between Context and Graphics Context?
2 Answers
"Context" almost always refers to a graphics context in Cocoa.
One exception is that various methods take a "context" argument, which is usually of type id
. This is generally just a spare argument for passing any data that you would like passed along to your callback(s).

- 3,831
- 1
- 22
- 24
Likely you're talking about the same thing in both cases. From the Quartz 2D Programming Guide:
A graphics context is an opaque data type (CGContextRef) that encapsulates the information Quartz uses to draw images to an output device, such as a PDF file, a bitmap, or a window on a display. The information inside a graphics context includes graphics drawing parameters and a device-specific representation of the paint on the page. All objects in Quartz are drawn to, or contained by, a graphics context.
You can think of a graphics context as a drawing destination, as shown in Figure 1-2. When you draw with Quartz, all device-specific characteristics are contained within the specific type of graphics context you use. In other words, you can draw the same image to a different device simply by providing a different graphics context to the same sequence of Quartz drawing routines. You do not need to perform any device-specific calculations; Quartz does it for you.
There is another definition for the word context in CS, but I think the above definition is what you're looking for.

- 1
- 1

- 27,575
- 16
- 91
- 128