Objective-C: message syntax vs. dot syntax; what's the difference?

穿精又带淫゛_ 提交于 2019-11-28 10:30:40

There is no functional difference between using dot syntax and using message syntax.

I find that using message syntax is more consistent with the language as a whole and that dot syntax was just implemented as a convenience to programmers who were coming over from languages that used it (Java comes to mind).

All I ask is: Whichever one you choose, be consistent with it. Do not mix and match single property setters! (Multiple-argument setters are obviously exempt).

They are the same.

The dot syntax is used to signify the access of @property's which you can also acces via:

[myObject setValue: [NSNumber numberWithIntValue:5] forKey:@"foo"];
[myObject valueForKey:@"foo"];

But in essence the calls are the same.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!