我有一个NSString
,我想检查它是否NULL
有价值。如果是这样,那么if
条件应该执行。否则它应该执行else
条件。
下面是我正在使用的代码:
if ([appDelegate.categoryName isEqual:[NSNull null]])
{
select = [[NSString alloc] initWithFormat:@"select * FROM ContentMaster LEFT JOIN Category ON ContentMaster.CategoryID=Category.CategoryID where ContentMaster.ContentTagText='%@'", appDelegate.tagInput];
}
else
{
select = [[NSString alloc] initWithFormat:@"select * FROM ContentMaster LEFT JOIN Category ON ContentMaster.CategoryID=Category.CategoryID LEFT JOIN Topic ON ContentMaster.TopicID=Topic.TopicID where ContentMaster.ContentTagText='%@' && Category.CategoryName='%@' && Topic.TopicName='%@'", appDelegate.tagInput, appDelegate.categoryName, appDelegate.topicName];
}
它总是执行else
条件,而不是if
条件,即使值为NULL
.