开发者

use if with NSinteger?

I WANT to use NSinteger variable *strength in my开发者_如何学JAVA code with if condition but it's not work.. :(

if(strength == 11){
}

How can i use if with NSInteger*


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.


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 *

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜