Annoying warning: Integer constant not in the range of enumerated type 'UIViewAnimationOptions'
c, ios, objective-c, xcode
Solution
You are doing nothing wrong. As you already noticed, the compiler complains because the value is none of the values defined in the enumeration. (The compiler flag `-Weverything` implies this check.)
You can suppress the warning either by an explicit cast:
options:(UIViewAnimationOptions)(UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat)
or with a `#pragma`:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wassign-enum"
[UIView animateWithDuration:0.5
delay:0
options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat
animations:^{
self.imgCheckIn.backgroundColor = [UIColor redColor];
}
completion:nil];
#pragma clang diagnostic pop
Problem
When writing code like the following in XCode 5 using clang set to C11/C++11: ``` [UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat animations:^{ self.imgCheckIn.backgroundColor = [UIColor redColor]; } completion:nil]; ``` The `options` field generates the following warning: ``` integer constant not in range of enumerated type 'UIViewAnimationOptions' (aka 'enum UIViewAnimationOptions') [-Wassign-enum] ``` The problem seems to be that the method takes a `UIViewAnimationOptions` type, which is just an enum of `NSUInteger`. However, OR'ing values together creates a value that isn't explicitly in the enum, so it complains. In general this seems to be a nice kind of warning to have so I'd like to keep it. Am I doing something wrong?