How to check the NULL value in NSString in iOS?

前端 未结 10 1525
盖世英雄少女心
盖世英雄少女心 2021-01-02 15:17

I have an NSString and I want to check if it has a NULL value. If it does, then the if condition should execute. Else it should execut

10条回答
  •  囚心锁ツ
    2021-01-02 15:58

    Try to use this. Check your value is kind of NULL class or not rather than comparing Pointers value.

    if ([appDelegate.categoryName isKindOfClass:[NSNull class]]){
    
            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];
    
    
        }
    

提交回复
热议问题