• 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: Stupid Cocoa question. How can you tell if the object you are looking at is a property or an ivar?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stupid Cocoa question. How can you tell if the object you are looking at is a property or an ivar?


  • Subject: Re: Stupid Cocoa question. How can you tell if the object you are looking at is a property or an ivar?
  • From: Graham Cox <email@hidden>
  • Date: Fri, 22 May 2015 09:44:37 +1000

> On 22 May 2015, at 3:02 am, Jens Alfke <email@hidden> wrote:
>
>> Now that I have a path forward and understand why things are what they are, this brings up the wonderful speed issue of "how much slower is property access vs ivar access”.
>
> Yeah, I think we’ve had some vigorous debates about this topic in the past.


Anecdotally, with some coarse measurements to confirm it, I changed a bunch of code in -initWithCoder: to set ivars directly instead of using the property accessors (or -set<Foo>:). For a very large object graph - I’m talking hundreds of thousands of objects - the speed-up was dramatic. Dearchiving that large file went from 11 MINUTES to about 2 seconds.

Because -initWithCoder: is an init method, setting ivars directly is par for the course, and at that time there can’t be any KVO observations depending on the property accessors, so it’s fine. However, if you have autosynthesized all your properties, to be completely safe and future-proof, you probably shouldn’t be doing this, even though right now the ivar names are predictable. That means that performance could be an issue with autosynthesized properties.

—Graham



_______________________________________________

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


  • Follow-Ups:
    • Re: Stupid Cocoa question. How can you tell if the object you are looking at is a property or an ivar?
      • From: John McCall <email@hidden>
References: 
 >Stupid Cocoa question. How can you tell if the object you are looking at is a property or an ivar? (From: Alex Zavatone <email@hidden>)
 >Re: Stupid Cocoa question. How can you tell if the object you are looking at is a property or an ivar? (From: Eric Wing <email@hidden>)
 >Re: Stupid Cocoa question. How can you tell if the object you are looking at is a property or an ivar? (From: Michael David Crawford <email@hidden>)
 >Re: Stupid Cocoa question. How can you tell if the object you are looking at is a property or an ivar? (From: Alex Zavatone <email@hidden>)
 >Re: Stupid Cocoa question. How can you tell if the object you are looking at is a property or an ivar? (From: Alex Zavatone <email@hidden>)
 >Re: Stupid Cocoa question. How can you tell if the object you are looking at is a property or an ivar? (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Stupid Cocoa question. How can you tell if the object you are looking at is a property or an ivar?
  • Next by Date: Re: NSFontPanel swamping the responder chain (and crashing)
  • Previous by thread: Re: Stupid Cocoa question. How can you tell if the object you are looking at is a property or an ivar?
  • Next by thread: Re: Stupid Cocoa question. How can you tell if the object you are looking at is a property or an ivar?
  • Index(es):
    • Date
    • Thread