相关疑难解决方法(0)

如何在iOS中检查NSString中的NULL值?

我有一个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];
}    
Run Code Online (Sandbox Code Playgroud)

它总是执行else条件,而不是if条件,即使值是NULL.

null nsstring ios

6
推荐指数
1
解决办法
3万
查看次数

标签 统计

ios ×1

nsstring ×1

null ×1