本地声明隐藏“self.treatmentId =treatmentId;”附近的实例变量消息弹出窗口和“self.treatmentName =treatmentName;”;
@implementation Treatment
@synthesize treatmentId;
@synthesize treatmentName;
-(Treatment *)initWithtreatmentName:(NSString *)treatmentName treatmentId:(NSString *)treatmentId{
if((self = [super init])){
self.treatmentId = treatmentId;
self.treatmentName = treatmentName;
}
return self;
}
@end
将您的代码更改为以下内容。
@implementation Treatment
@synthesize treatmentId;
@synthesize treatmentName;
-(Treatment *)initWithtreatmentName:(NSString *)newTreatmentName treatmentId:(NSString *)newTreatmentId{
if((self = [super init])){
self.treatmentId = newTreatmentId;
self.treatmentName = newTreatmentName;
}
return self;
}
@end
通过声明局部变量trentmentName
and treatmentId
您基本上失去了通过名称访问全局(iVar)的能力。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)