开发者

Protocols in Objective C

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜