您在Objective-C中ID变量的替代名称是什么? [英] What is your alternative name for ID variable in Objective-C?

查看:60
本文介绍了您在Objective-C中ID变量的替代名称是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于"id"是Objective-C中的关键字,您为ID变量(例如PK字段)使用了什么替代名称?

我认为应该指出,编译器可以区分类型说明符位置的id和变量名称位置的id.也就是说,

NSUInteger id;
id = 10;

可以很好地编译(实际上,id id; id = [NSNumber numberWithInt:10];也可以). (您也可以将其大写:ID.)也就是说,这些都是可怕的想法.不要使用它们.忘了我什至这么说.

可可编程中的风格倾向于趋于冗长,因此(如所有先前的答案所建议的那样),最佳实践可能是将其全部写出:identifierdinglehopferID.

Since "id" is a keyword in Objective-C what alternative name do you use for ID variable (e.g. PK field)?

解决方案

I think it should be noted that the compiler can distinguish between id in the type specifier position and id in the variable name position. That is,

NSUInteger id;
id = 10;

will compile just fine (as, indeed, will id id; id = [NSNumber numberWithInt:10];). (You could also uppercase it: ID.) That said, those are all horrible ideas. Don't use them. Forget I even said that.

The style in Cocoa programming is to tend towards verbosity, so (as all the earlier answers have suggested) the best practice is probably to write it all out: identifier or dinglehopferID.

这篇关于您在Objective-C中ID变量的替代名称是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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