我想在parse.com上使用字符串来设置UILabel中的文本。在解析我有一个名为“isItemOnSpecial”的字符串列,如果该项目是特殊的,我会将它设置为yes。如果字符串设置为yes,那么我希望UILabel显示来自列specialPrice的字符串othwerwise我想UILabel被隐藏。这里是我的代码:使用“isEqualToString”设置标签文本
// This is where I am setting up my tableViewCell//
NSString *itemOnSpecial = [object objectForKey:@"isItemOnSpecial"];
if ([itemOnSpecial isEqualToString:@"yes"]) {
UILabel *specialLabel = (UILabel*) [cell viewWithTag:5];
specialLabel.text = [object objectForKey:@"specialPrice"];
} else {
UILabel *specialLabel = (UILabel*) [cell viewWithTag:5];
[specialLabel setHidden:true];
}
当我运行该应用程序使用此代码UILabel总是设置隐藏。 任何与此有关的帮助将非常感激,它一直在困扰着我很长一段时间。
谢谢你的时间。
'[object objectForKey:@“isItemOnSpecial”]''的输出是什么? – Desdenova
yah..check'NSLog(@“%@”,[object objectForKey:@“isItemOnSpecial”]);' – preetam
'if([@“Some String”caseInsensitiveCompare:@“yes”] == NSOrderedSame)'try this – Buntylm