I have the following and it throws me an incompatible error integer to pointer ...
int *v = [numero intValue];
NSLog(@"Numero %d",v);
Where number is a NSNumber
.
How would you do to print a int
? And a NSInteger
?
I have the following and it throws me an incompatible error integer to pointer ...
int *v = [numero intValue];
NSLog(@"Numero %d",v);
Where number is a NSNumber
.
How would you do to print a int
? And a NSInteger
?
I understand that numero
is declared as NSNumber
with something of this style:
@property (strong, nonatomic) NSNumber *numero;
And what you want is to assign it to i
which is a int
.
The problem is that NSNumber
is an object and the variable i
is a int
that is a primitive type. This means that numero
will be a pointer to some place in the memory, that's why the *
in the declaration, but i
is not an object, so you do not need the *
in the declaration.
If you do this, it will work properly for you:
int i = [self.numero integerValue];
NSLog(@"numero %d", i);