您在Objective-C中ID变量的替代名称是什么? [英] What is your alternative name for ID variable in Objective-C?
问题描述
由于"id"是Objective-C中的关键字,您为ID变量(例如PK字段)使用了什么替代名称?
我认为应该指出,编译器可以区分类型说明符位置的id
和变量名称位置的id
.也就是说,NSUInteger id;
id = 10;
可以很好地编译(实际上,id id; id = [NSNumber numberWithInt:10];
也可以). (您也可以将其大写:ID
.)也就是说,这些都是可怕的想法.不要使用它们.忘了我什至这么说.
可可编程中的风格倾向于趋于冗长,因此(如所有先前的答案所建议的那样),最佳实践可能是将其全部写出:identifier
或dinglehopferID
.
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屋!