ios - Using property accessors on viewDidLoad - Objective C -


as far know should use accessors access or modify property, except in 2 scenarios:

  • init
  • dealloc

don’t use accessor methods in initializer methods , dealloc places shouldn’t use accessor methods set instance variable in initializer methods , dealloc. initialize counter object number object representing zero, might implement init.

this exceptions because calling accessors when view not initialised might raise issues when overriding setters/getters (https://developer.apple.com/library/mac/documentation/cocoa/conceptual/memorymgmt/articles/mmpractical.html)

so, according use of accessors on viewdidload should fine, , recommended, in of codes available on internet developers use _ivars on viewdidload , wonder why. there reason using property _ivars instead of accessors in viewdidload?

one of valuable post using accessors in init/dealloc method https://www.mikeash.com/pyblog/friday-qa-2009-11-27-using-accessors-in-init-and-dealloc.html


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

android - CoordinatorLayout, FAB and container layout conflict -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -