My question is: is UItextInputTraits a pr开发者_Python百科otocol ?? if yes why does it have instances variables ?
Thanks
Yes it is a protocol, and no it does not have instance variables. It has properties, which are just syntactic sugar for methods.
A property does not need to be backed by an instance variable at all; not in a class definition or a protocol (in the latter it can't just by the nature of how protocols work). All it cares about is that, for instance, in the case of a protocol named foo
two methods exist if it's readwrite
:
- foo
- setFoo:
Obviously, returning and taking the appropriate data type.
精彩评论