English 中文(简体)
可可:你如何用不干扰岩浆来命名你的内分泌参数?
原标题:Cocoa : how do you name your init parameters for not interfering with ivars?

首先举个例子:

@interface myClass : NSObject {
    NSString * title;
}

-(id)initWithTitle:(NSString*)title;

编纂器不喜欢这样, 因为标题 Init 参数隐藏了 MyClass 标题 ivar 。

但我不喜欢这些选择:

-(id)initWithTitle:(NSString*)t;
-(id)initWithTitle:(NSString*)myTitle;
-(id)initWithTitle:(NSString*)_title;

所以这是民意测验: 你们的大会是什么?

最佳回答

有些人更喜欢调用他们的 ivars title title title , 然后他们就可以在函数中使用 title 作为参数名称。 或者你称之为 Title newTitle 。 没有正确或错误的方法可以这样做 。

问题回答

我更喜欢使用 -(id)initoutoutTittle: (NSString *) atitle;

我目前使用 ptle ,但多年来一直使用 intil





相关问题
Allow user to change the default web part styles

I have a web part which uses many SharePoint controls like menu, SPGrid, tool bar etc. I want the user to be able to change the style by specifying an external CSS file. Can somebody tell me how I ...

using jqgrid style for usual Table in asp.net mvc

I d prefer using Table and td instead of JqGrid but i like JqGrid styles. has anyone used jqgrid style for usual Grid of asp.net MVC(i mean Table and td) before?