Re: [Learning Cocoa Qs] View Hierarchy & Pointers to Cocoa data structures
Re: [Learning Cocoa Qs] View Hierarchy & Pointers to Cocoa data structures
- Subject: Re: [Learning Cocoa Qs] View Hierarchy & Pointers to Cocoa data structures
- From: Chris Gehlker <email@hidden>
- Date: Sun, 08 Jul 2001 06:32:21 -0700
On 7/8/01 5:37 AM, "Dale Gillard" <email@hidden> wrote:
>
I have 2 questions from the Learning Cocoa book I'm hoping people can
>
help me with:
I'm just going through the book myself but I'll take a shot.
>
QUESTION 1
>
Page 127 shows figure 8-3. It depicts the view hierarchy of a window
>
with 3 views: A, B and C. A is the window view containing views B and C.
>
What I don't understand is that the hierarchy has 2 NSWindows sitting
>
between the NSApplication and NSView 'A'. Shouldn't there only be 1
>
NSWindow?
I think the second window is just to illustrate that an NSApplication can
have multiple windows. Only the upper window corresponds to "Untitled 1" in
the figure.
>
QUESTION 2
>
OK. My second question relates to the Dot View project on pages 133 -
>
138. Page 135 contains example 8-1. It's code declaring a header file
>
for DotView, including these 2 variables:
>
NSPoint center;
>
NSColor *color;
>
>
My question is: why is one a variable, and the other a pointer to a
>
variable? Is this because the NSPoint class always returns an object of
>
NSPoint when it's created? And that the NSColor class returns a pointer
>
to a NSColour object when it is instantiated?
>
>
I've had a look in the Cocoa Help but can't find any info for NSPoint
>
(Objective C version). (There is a Java version of the help info in
>
Cocoa Help.) I've also had a look for and found the NSColor Cocoa Help
>
info. But I can't find where is says what is returned when an object of
>
this type is instantiated. That is, whether it's a pointer or a variable.
>
>
Am I missing something in the help documentation? Am I missingn
>
something in my knowledge of C (I've done some C++ at university). If
>
not, how do others know whether to declare a variable or a pointer to a
>
variable?
An NSPoint isn't a object, just a struct. It's being returned by value. The
best way to find these things is to index your project and then search for
the definition of NSPoint or whatever using the "Find" pane.
--
Times are bad. Children no longer obey their parents, and everyone is
writing a book. -Marcus Tullius Cicero, statesman, orator and writer
(106-43 BCE)