【问题标题】:not able to compare (null) [duplicate]无法比较(空)[重复]
【发布时间】:2012-07-19 15:43:02
【问题描述】:

可能重复:
What is the right way to check for a null string in Objective-C?

如果我的 url 为空,我应该将 url 变量分配为空..我已经尝试过但仍然没有在我的 IF 语句中输入。我什至尝试过这个if([url isEqualToString:@""]) 但它是徒劳的 下面是代码

-(void)newView:(NSString *)title Description:(NSString *)desc URL:(NSString *)url{
self.tblTwitter.userInteractionEnabled=NO;
self.tblFacebook.userInteractionEnabled=NO;

if (![url isEqualToString:@""])
{
    //
    NSLog(@"the perfect Value:%@",url);
 //   url=@"boom";
}
webView =[[UIWebView alloc]initWithFrame:CGRectMake(15, 25, 190, 190)];
webView.backgroundColor=[UIColor clearColor];
webView.delegate=self;
webView.opaque = NO;

【问题讨论】:

    标签: objective-c xcode


    【解决方案1】:

    你试过了吗:

    if (url == nil)
    

    nil 是 Objective-C 中的 NULL,nil 不代表空。

    这个答案可能就是你要找的:What is the right way to check for a null string in Objective-C?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-08
      • 1970-01-01
      • 1970-01-01
      • 2019-05-04
      • 1970-01-01
      • 1970-01-01
      • 2020-02-13
      • 1970-01-01
      相关资源
      最近更新 更多