use if with NSinteger?
Asked Answered
P

2

1

I WANT to use NSinteger variable *strength in my code with if condition but it's not work.. :(

if(strength == 11){
}

How can i use if with NSInteger*

Protasis answered 25/1, 2011 at 8:8 Comment(1)
Why with a *? NSInteger is not an object.Betroth
W
11

NSInteger is a primitive value type; you don't really need to use pointers. So your declaration should read

NSInteger strength;

And not

NSInteger *strength;

However if you do need to use a pointer to an NSInteger (that is, NSInteger *) for some reason, then you need to dereference the pointer to get the value:

if (*strength == 11) {
}

but from what I see, I don't think this is the case.

Weep answered 25/1, 2011 at 8:12 Comment(0)
K
0

I assume you must be adding an * when you declare your strength variable. You shouldn't have it because NSInteger is a primitive type.

Why don't I declare NSInteger with a *

Kooky answered 25/1, 2011 at 8:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.