为什么Objective-C中的所有东西都是由*小写创建的? [英] Why are all things in Objective-C created by * lower case?

查看:130
本文介绍了为什么Objective-C中的所有东西都是由*小写创建的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很困惑这个事情。在任何教程,github和文档我看到的代码BOOLs,NSStrings,NDDictionaries等都以小写开头。例如。 NSString * aString这是必要的吗?如果我在创建BOOL等时使用大写,什么都会毁了?我真的很困惑这里:P任何帮助是非常感谢!

I'm really confused about this thing. In any tutorial, code on github and documentation I have seen BOOLs, NSStrings, NDDictionaries etc all start in lower case. Eg. NSString *aString Is this necessary? Will anything get ruined if I use upper-case while creating BOOLs etc? I'm really confused here :P Any help is greatly appreciated!

编辑:将使用下划线,然后声明变量在首都是好主意?

Will using an underscore and then declaring variables in Capitals be a good idea?

推荐答案

添加自评论

它更多的是一个编码标准的事情。我刚刚参加了我的SCJP考试,他们有一整章关于编码标准。它由程序员如何他们在那里开发代码,但想想谁必须修改它。使用资本会使它更容易阅读,或只是使它更难。我的建议是坚持编码标准,因为大多数开发人员都理解它们。

Its more of a coding standards thing. I have just taken my SCJP exam and they have an entire chapter on coding standards. Its up to the programmer how they develop there code but think about the person who has to make amendments to it. Will using capitals make it easier to read or just make it harder. My recommendation is to stick with the coding standards as most developers understand them.

在编码标准下,你通常使用一个资本和以小写字母开头的变量声明你的类。这是因为它不会混淆其他开发人员,当修改,更重要的是,它不会混淆你。

Also under coding standards you would normally Have your Classes declared with a capital and variables starting with lower case. This is so it doesn't confuse other developers when make amendments and more importantly so it doesn't confuse you. It wouldn't be good if you got confused by your own code.

但标准说应该是这样:

 NSString *nsString; // Not that you should be having a variable like this. But stops the any confusion.
 [nsString uppercaseString];

如果你有这个会开始混淆

it would start to get confusing if you had this

 // Compile won't actually let you have this just an example of confusion and reserved words. 
 NSString *NSString;
 [NSString uppercaseString];

在编码标准中,必须有经验的开发人员知道,从资本开始的任何东西通常是一个类,小写是一个变量。这几乎是所有的编程语言。在学习 prolog 时,我确实发现了编码标准的混乱。

In coding standards must experienced developers know that anything starting with a capital is generally a class and anything starting with lower case is a variable. This is in almost all programming languages. I did see a bit of confusion around coding standards when studying prolog.

像Sun一样,苹果有编码标准此处

Like Sun, Apple have there coding standards here

这篇关于为什么Objective-C中的所有东西都是由*小写创建的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆