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