Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 未使用的实体问题_Ios_Objective C_Xcode - Fatal编程技术网

Ios 未使用的实体问题

Ios 未使用的实体问题,ios,objective-c,xcode,Ios,Objective C,Xcode,我从第4行(对于注销变量)的以下代码中得到“未使用的实体问题”警告。但我正在使用它。那么它为什么没有被使用呢 NSString *actionSheetTitle = @"xxxx"; NSString *tour = @"xxxx"; NSString *feedBack = @"xxxx"; NSString *logout = @"Log Out"; #ifdef XXXX UIAct

我从第4行(对于注销变量)的以下代码中得到“未使用的实体问题”警告。但我正在使用它。那么它为什么没有被使用呢

        NSString *actionSheetTitle = @"xxxx";
        NSString *tour = @"xxxx";
        NSString *feedBack = @"xxxx";
        NSString *logout = @"Log Out";

        #ifdef XXXX
            UIActionSheet *actionSheet = [[UIActionSheet alloc]
                                          initWithTitle:actionSheetTitle
                                          delegate:self
                                          cancelButtonTitle:@""
                                          destructiveButtonTitle:nil
                                          otherButtonTitles:tour, feedBack, logout, nil];
            [actionSheet setCancelButtonIndex:3];
        #else

            UIActionSheet *actionSheet = [[UIActionSheet alloc]
                                          initWithTitle:actionSheetTitle
                                          delegate:self
                                          cancelButtonTitle:@""
                                          destructiveButtonTitle:nil
                                          otherButtonTitles:tour, feedBack, nil];

            [actionSheet setCancelButtonIndex:2];
        #endif

    }
当您使用#ifdef和#else时,Xcode会“隐藏”其中一个部分


这就是为什么它不把它看作是代码的一部分,并意识到你。

在另一个条件中,你没有使用“注销”。如果没有,else块将只可见,因此注销实体将被视为未使用,通过将NSString*logout=@“logout”放入其中来解决它;以下为ifdef XXXX