Re: Struct Data Types
Re: Struct Data Types
- Subject: Re: Struct Data Types
- From: Uli Kusterer <email@hidden>
- Date: Sun, 19 Aug 2007 20:59:54 +0200
On 17.08.2007, at 02:57, Richard Somers wrote:
Why didn't Apple design struct data types like this?
- (NSRect *)frame
Is it because when ever you see the parameter type (NSFoo *) you
should think object and when ever you see the parameter type
(NSBar) you should think struct?
It's because by returning it by value instead of as a pointer you
don't have to memory-manage it. After all, where would the actual
NSRect being pointed to be allocated, and who would take care of
freeing it? structs don't respond to messages, so you wouldn't be
able to release it. Not to mention that NSRect is a fairly small
struct. On many modern machines, 16 bytes are copied just as quickly
as an int.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden