我只是试图根据某些逻辑将布尔值设置为true。无法访问布尔值的属性
这是我的代码。
我设置了两个属性。
@property (nonatomic) BOOL stoneSwitch;
@property (nonatomic) BOOL cystSwitch;
这里是一个动作我已经在我的故事板
- (IBAction)switcherAction:(id)sender
{
if (self.customSwitcher.isOn) {
if ([self.customLabel.text isEqual:@"Stone Manip"]) {
NSLog(@"%d",self.cystSwitch);
if (self.cystSwitch == TRUE) {
[self.customSwitcher setOn:YES];
self.stoneSwitch = TRUE;
} else {
[self.customSwitcher setOn:NO];
}
} else {
self.cystSwitch = TRUE;
}
}
[self.delegate updateField:self.fieldName withBoolValue:self.customSwitcher.isOn];
}
-(void)setPlaceHolder:(NSString*)placeHolder
{
[super setPlaceHolder:placeHolder];
_customLabel.text = placeHolder;
}
我重新登录了我的上述cystSwitch布尔但它始终保持设置了开关0缺少什么我在这里?
编辑一个:
- (IBAction)switcherAction:(id)sender
{
if ([self.customLabel.text isEqual:@"Stone Manip"]) {
NSLog(@"%d",self.cystSwitch);
if (self.cystSwitch == TRUE) {
[self.customSwitcher setOn:YES];
self.stoneSwitch = TRUE;
} else {
[self.customSwitcher setOn:NO];
}
} else {
self.cystSwitch = TRUE;
NSLog(@"%d",self.cystSwitch);
[self.customSwitcher setOn:YES];
}
[self.delegate updateField:self.fieldName withBoolValue:self.customSwitcher.isOn];
}
我发现,如果我登录我的self.cystSwitch出下else条件,它并正确反映,但重置一旦它开始。这是因为我没有为我的属性使用指针?
什么是'self.customLabel'?它是否被设置为“@”Stone Manip“'? – Hamish
自定义标签始终是交换机设置时提供的文本。它保持不变,我可以通过我的调试器和控制台验证它是否总是进入日志。日志总是告诉我0。 – wowzuzz
是的,有两个开关叫。一个是“Stone Manip”和另一个是“Cysto/Stent”。这两个文本可以根据调用哪个开关而不同。 – wowzuzz