Background
A variable in a programming language is a box which has a name (sometimes termed a "reference" or a "pointer' depending on the language). This box contains a value of some type. Values don't change, the contents of boxes do. E.g in the following code:
int a = 4;
a = 5;
The second line doesn't change 4
, it changes what is in box a
.
Types in programming languages fall into two categories: value types and reference types.
For value types what gets passed around and stored in boxes is a representation of the actual value, e.g. in the code:
double a = 9.0;
double b = sqrt(a);
The function sqrt
is not passed a
but the value that is stored in a
- which is some sequence of bits which represent the number 9.0; what is returned by sqrt
is some sequence of bits which represent 3.0, and these are stored into b
. The bits that are passed around, you use your words in one of your comments, are the "real value".
For reference types what gets passed around and stored in boxes is some representation of the name of the box (chunk of memory) which contains the actual value. In Objective-C reference types are distinguished by using *
in their declaration (other languages don't require a *
, e.g. Java & C# - they know which types are reference types based on their kind). E.g in the code:
NSWindow *main = [NSApp mainWindow];
the method call doesn't return a window value itself but the name of a box containing the window value. Again to use your words, the "real value" is never passed around rather the name of a box containing that value is passed around.
Traditionally "small" types were represented by value types - integers, floating point numbers, characters, etc.; while "large" values by reference types. However each programming languages makes its own choices - some are even defined to only operate with reference types.
Answer
In your example myView.frame
is a property, and a property is implemented using a method. In Objective-C (and C, C++) a struct
type is a value type - it is treated just like integers and floating point numbers, it's value is passed around and stored in boxes. So what is returned by the property is, using your words, the "real struct" - it's as "real" as the bits representing 3.0 in the above example.
What isn't being returned is the name of the box containing a struct value, and without access to a box you can't change its contents. Which is why myView.frame.size.height = 36.0;
is incorrect - you're trying to change part of a value, and values don't change.
However given an NSRect
box you can change part of its contents. E.g. in the code:
NSRect aRect;
aRect.size.height = 36.0;
The .size.height
is identifying which part of the box aRect
to change, and the representation of 36.0
is stored into that part of the box.
HTH