This question gets back to the basics of C
programming (i.e. non-object-oriented programming).
When you use a property that refers to a struct, you are grabbing a copy of that struct, not a reference to it.
If you write
CGRect rect = CGRectMake(...);
CGRect rect2 = rect;
You are not assigning rect2
a reference to rect
, you are creating a copy of the struct. Changing rect2
does not change rect
.
Similarly, if you change an element of a struct returned as a property, you are changing the element of a copy of the rect owned by your object. There is literally NO good that can come of this -- there is no use for this sort of code because you are changing the value of an element of a struct that there is no reference to anywhere.
If you wanted to edit the struct that was actually being used by the class, your property would need to return a pointer to it. This can be done, but the code becomes messier than it is worth:
typedef struct myObj{BOOL isUp;} TOBJECT;
...
@property (nonatomic, assign) TOBJECT* myObj; //in class interface
...
self.myObj = malloc(sizeof(TOBJECT)); //in init method.
...
self.myObj->isUp = YES; //elsewhere, even potentially outside the class.
...
free(self.myObj); //in class dealloc method.