I'm new to Objective C. Here's my code
enum effectName {
RESET, Flea,Tint,Grayscale,Pixelate,Blur,Mirror,changeBrightness,changeContrast,Invert
};
enum effectName EffectToApply;
enum effectName prevEffect;
and in the implementation file, I've to declare EffectToApply and prevEffect as null. I tried doing it like this
-(void) Effect
{
EffectToApply= NULL;
prevEffect=nil;
}
but it gives a warning Incompatible pointer to integer conversion. Can someone help me how to do this?
An enum is effectively an integer and, like an integer, such a type cannot represent a NULL value discreet from 0 in either C or Objective-C1
The simplest way to deal with this is to have a "NONE" enum option, generally with the value 0.
enum effectName {
NoEffect, ResetEffect, ..
};
enum effectName EffectToApply; // default value => 0 / NoEffect
1 See Can a conforming C implementation #define NULL to be something wacky for a lot of C-lawyer speak wrt how NULL is defined; some libraries define NULL as 0 or 0L, which while permissible would (unfortunately) not have emitted the observed warnings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With