As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center作为指导。
                            
                        
                    
                
                                7年前关闭。
            
                    
我正在从一本“新书”中学习到这一点,但我想知道当前在将点运算符用于设置属性值之外的事情时的标准是什么。

就像在方法调用中一样。显然myClass.myMethod:value在语法上是正确的,但是现在它是公认的规范吗?

在我看来,点运算符比[myClass myMethod:myValue]具有更多的“人为”感觉。

最佳答案

您是否尝试过编译?据我了解,您的myClass.myMethod:value示例无效。

编译器将点运算符转换为-(void)setMyValue:(ValueType*)-(ValueType*)myValue,具体取决于您是获取还是对其进行设置。

阅读苹果文档以获取更多信息:
http://developer.apple.com/library/ios/documentation/cocoa/conceptual/objectivec/Chapters/ocObjectsClasses.html#//apple_ref/doc/uid/TP30001163-CH11-SW17

关于objective-c - 如今的 objective-c 点运算符,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12712095/

10-10 11:29