Objective-C 不同语法问题
我现在正在学习 Objective-C,所以请耐心等待。
据我了解,编写 Objective-C 时的一般语法(使用属性时除外)如下所示:
[object method];
[object methodWithArgument:1 arg2:2];
现在,在阅读 iOS 设备的文件输入/输出时,令我感到困惑的是,该示例告诉我使用一种方法来获取应用程序的文档文件夹:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
这是怎么回事?
I'm learning Objective-C at the moment so bear with me.
As I understand the general syntax (except when using properties) when coding Objective-C looks something like this:
[object method];
[object methodWithArgument:1 arg2:2];
Now to my confusion when reading upon file input/output for iOS devices, the example tells me to use a method to get the Application's documents folder:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
What is going on here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
第一个是用于调用方法的 Objective C 语法,
第二个代码片段使用 C 语法来调用函数。
Objective C 是 C 的超集
The first is Objective C syntax for calling methods
The second snippet uses C syntax for calling functions.
Objective C is a superset of C
第一种语法用于调用类的成员方法,第二种语法用于调用独立函数。 Objective-c 是 C 的超集,这意味着它具有 C 的所有功能(包括函数)以及类等的 OO 功能
The first syntax is for calling member methods of a class, the second is for invoking standalone functions. Objective-c is a superset of C meaning it has all of the features of C (including functions) along with the OO features of classes and the like