I ran into an issue " Cannot use instance member'XXX' within property initializer,property initializers run before 'self' is available " Can you tell me what's this talking about and what's the difference between 'instance member' and 'property' ? I even thought they were exactly the same! Isn't 'instance' just like a 'class',and isn't its member a property?
Asked
Active
Viewed 384 times
0
-
2I don't think the linked dupe targets completely answer the question – an instance member is simply something that's available to call on an *instance* of a type. This could be an instance property or method. *Static* properties and methods are *not* instance members, as they're called on a type, rather than an instance of a type. – Hamish Mar 26 '17 at 12:56
-
Hi,Mr.Hamish,as for " Cannot use instance member'XXX' within property initializer,property initializers run before 'self' is available " ,can I put it this way "Before the whole class is even made, I am absolutely NOT allowed to use the property of this class to initiate another property" ? – Qasa iNto Mar 27 '17 at 13:30
-
1Basically, yes – you cannot refer to `self` (and therefore any instance members, as they're called on `self`) *before* `self` is fully initialised (i.e before the instance of the class is fully created). – Hamish Mar 27 '17 at 21:00