• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Struct Data Types
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Struct Data Types (From: Richard Somers <email@hidden>)

  • Prev by Date: Re: Problem with NSMutableDictionary
  • Next by Date: Re: CoverFlow on 10.4
  • Previous by thread: Re: Struct Data Types
  • Next by thread: "Esc" doesn't work as a menu item key equivalent
  • Index(es):
    • Date
    • Thread