简体   繁体   English

遵守仅由@property组成的协议是什么意思

[英]What does it mean to conform to a protocol consisting of only @property

I am trying to understand someone's code and ran into this. 我试图理解某人的代码并遇到了这种情况。

There is a header file in which there is a protocol that specify a property of a UIButton. 有一个头文件,其中有一个指定UIButton属性的协议。

In a separate implementation file (not the implementation for this header file), it was checking if a view controller "conformsToProtocol" 在一个单独的实现文件(不是此头文件的实现)中,它正在检查视图控制器是否“ conformsToProtocol”

I understand if you have to conform to a protocol of methods, you have to implement those methods. 我了解如果您必须遵守方法协议,则必须实现这些方法。 But here, 但在这儿,

What constitute conform and non-conform here? 在这里什么构成合格和不合格?

It means that whatever conforms to that protocol must have the specified properties. 这意味着符合该协议的任何内容都必须具有指定的属性。 (Remember, @properties are basically just shorthand for the underlying setter and getter methods, so you can also conform by having the appropriate setters and getters.) (请记住,@ properties基本上只是底层setter和getter方法的简写,因此您也可以通过具有适当的setter和getter来遵循。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM