I want to declare a NSInteger variable in my ViewController, but I get an error.
In my ViewController.h I have
@interface MainViewController : UIViewController{
NSInteger currentSection;
//Other stuff
}
@property (assign,nonatomic) NSUInteger currentSection;
@end
and in my ViewController.m I have:
@implementation MainViewController
//Other stuff
@synthesize currentSection;
But I get this error:
Type of property ‘currentSection’ (‘NSUinteger’ (aka ‘unsigned int’)) does not match type of ivar ‘currentSection’ (‘int’)
Why do I get this error with one simple instruction?
I’m using Xcode 4.4 with ARC.
You are asking the compiler to synthesize a
NSUIntegerproperty with aNSIntegerivar. You have to decide what the type of the property should be and adapt the type of the ivar accordingly.Note that unsigned integer are not equivalent to (implicitly signed) integer. Casting one to the other might give you unexpected results.