C Structs as objects?
C Structs as objects?
- Subject: C Structs as objects?
- From: Jeff LaMarche <email@hidden>
- Date: Wed, 17 Oct 2001 09:07:08 -0700
I haven't seen anything documented about this in "Object Oriented
Programming and the Objective-C Language", but it seems that C-style
structs such as NSRect and NSSize are much more user friendly than
structs in plain old C. For example:
Project builder allowed me to do this (this is from memory, so forgive
me if it's not quite right):
NSSize mySize;
mySize = [myWindow frame].size;
In C, IIRC, you could absolutely not assign a struct to a struct simply
by saying
destStruct = srcStruct;
You would have to copy the individual members or do a block copy or some
other not-particularly-intuitive copy method.
Does this mean that structs behave as objects much as if they were
actually objects subclassed from NSObject, or does it just that
Objective-C has extended C by allowing this more intuitive manner of
assigning structs to structs?