• 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: Setters, Getters and efficiency
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setters, Getters and efficiency


  • Subject: Re: Setters, Getters and efficiency
  • From: Jeff LaMarche <email@hidden>
  • Date: Sun, 11 Dec 2005 09:15:48 -0500

On Dec 11, 2005, at 7:37 AM, Bruce Truax wrote:

Cocoa bindings work whether you have specific setters and getters for a
variable or if you simply define the variable in your header file with no
specific accessors. Can anyone comment on which method is the most
efficient in terms of execution time?

The difference should be minimal, and will depend on whether you are binding to a class instance or a managed object (Core Data).

When binding to a class instance, it will look first for an accessor method, and only use the instance variable after making three attempts at using an accessor (e.g. if you bind to foo, it will look for getFoo, foo, and isFoo) before it will get the instance variable, so you're actually going to see worse performance if you don't implement your accessors.

When binding to a managed object (either directly to Core Data, or to NSManagedObject or a subclass of NSManagedObject), then it will prefer direct access and will look for an accessor only if it fails to find something going directly (i.e. if you've got a virtual accessor).

So, in other words, there's no performance benefit to be had by not implementing your accessor and mutator methods. In any situation where it would be faster not to have it, it would bypass the accessor or mutator anyway.

Hope this helps.
Jeff
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: Setters, Getters and efficiency
      • From: mmalcolm crawford <email@hidden>
References: 
 >Setters, Getters and efficiency (From: Bruce Truax <email@hidden>)

  • Prev by Date: Setters, Getters and efficiency
  • Next by Date: Re: Audio & Video Capture
  • Previous by thread: Setters, Getters and efficiency
  • Next by thread: Re: Setters, Getters and efficiency
  • Index(es):
    • Date
    • Thread