I try to write on Objective C and I encountered such a thing:
self.updateInterface;
Gives out Warning, and
[self updateInterface];
Not.
Why it happens?
I try to write on Objective C and I encountered such a thing:
self.updateInterface;
Gives out Warning, and
[self updateInterface];
Not.
Why it happens?
Very well discussed here:
Here is a brief retelling of the free-form answer accepted there:
Do not use dot for behavior. Use dot to access or set attribute like stuff, typically attributes declared as properties.
That is, the point can and, as many consider, desirable, be used for properties declared using @property and cannot (undesirable, though not impossible;)) be used for behavior, that is, for selectors.
So, for example, in the case of updateInterface (this is a selector, that is, behavior) you need to write via [self updateInterface], but for, say, view.subviews is better to use for (NSView *v in myView.subviews) { ... };
, not for (NSView *v in [myView subviews]) { ... };
See also a good answer about the pros and cons of using the dot: Dot notation pros and cons, https://stackoverflow.com/a/10370847/598057
Source: https://ru.stackoverflow.com/questions/198512/
All Articles
self.updateInterface;
I wanted to call the updateInterface method. - Niki-Timofeself.updateInterface;
- so you can refer to the property. And methods are always called through square brackets, more precisely, a message is sent to the object. Obj-C has a slightly specific syntax, so it’s better to read the theory. For example, it is well written here - habrahabr.ru/post/107126 - Tuggen