instance-variables


On benefits of using ivar variables instead of getters


Though i am using Objective-C syntax, the question language agnostic.
Assuming the following declaration
#synthesize activities = _activities;
self.activities will call the getter and _activities will check for the value which was already assigned. The main benefit of this assignment, as i understand it, is to clearly differentiate when setter is called and when local variables is called instead.
While this is nice, what is the real tangible benefit of using ivar vs using getter methods?
I can think of one, what are others?
I suppose using ivar is faster then calling the getter, but compared with what goes on with touch events, the difference is negligible.
Accessing the instance variables directly means circumventing any atomicity protection and memory management supplied by the synthesized accessors. If it's clear when you're doing that, it's easier to audit such access to ensure that you're looking after these aspects of the class's behaviour yourself.

Related Links

Passing a return `NSString` variable from a class ( `+(id)` ) to another view controller class
On benefits of using ivar variables instead of getters
Instance variable in Stripes

Categories

HOME
flask
firebase
memory
xcode8.1
d3.js
devexpress
stacktrace.js
iverilog
twitter-fabric
moodle-api
drag-and-drop
azure-mobile-services
sentry
ag-grid
native-base
eddystone
bellman-ford
fireloop
clish
bootstrap-switch
pushdown-automaton
c#-7.0
rpmbuild
angular2-highcharts
jitsi
maven-surefire-plugin
opentext
web-push
gravity-forms-plugin
microprocessors
javax.persistence
materialize
dotcms
autodesk-model-derivative
objectmapper
netbios
riotjs
mongoengine
counting
adminer
autoencoder
buildforge
formsauthenticationticket
cordys-opentext
jade4j
django-smart-selects
llvm-ir
linq.js
oauth2
suds
system-on-chip
coverage.py
robust
xcode8.2
android-5.0-lollipop
jgrapht
android-sharing
fitbit
e
msg
jpda
jsf-2.3
fiber
jemdoc
verisign
mousehover
chicagoboss
supersocket.net
google-gdk
alwayson
shell-extensions
mathematical-expressions
baseadapter
nanomsg
lifetime
multivariate-testing
visual-studio-6
property-injection
pbkdf2
mute
postgres-xc
dynamic-rdlc-generation
2d-vector
jsplitpane
gprof
ip-geolocation
getopt-long
msinfo32
expression-web
server-variables
vows
filelock
asp.net-mvc-views
printqueue
anonymous-types
mysqli-multi-query
external-sorting
ntruencrypt
motif
acceleration
code-camp
service-factory

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App