When to use @property?

Should it be used @propertyfor variables that will be accessed very often, for example, about the position of a particle? @propertycreates getters and setter for the variable, which adds the overhead of the method call. In most cases, this is not noticeable, but what if access to the resource reaches up to a million times per second (in different cases)?

+3
source share
3 answers

You are correct that the Objective-C runtime will add a certain amount of overhead to @propertyaccessors. However, this is a common way to exchange information between Objective-C classes. You should consider a different approach if you measured your application and determined that service data @propertyis actually a processing bottleneck.

Keep in mind that a modern processor operates in the GHz band, and something happens "a million times per second" only in the MHz band. Most likely, your bottlenecks will be somewhere else.

, Particle Objective-C ParticleCloud. Particle, @property accessors.

+4

? , . , . , , - , . , , . , FASTER w/@property, , .

+1

-, @property . , , "" , . , , .

One of the benefits of @property is that you can specify whether you want them to be read-only (i.e. no setter). So this is really a public API issue.

0
source

All Articles