Reputation: 85
I have a variable Player1Visits
which is declared as int
.
If I try to compare this to 1 using Player1Visits == 1
I get the warning comparison between integer and pointer. Should I be using a different type?
Upvotes: 3
Views: 4872
Reputation: 95335
You haven't declared it as int
, the compiler warning gives that away. Perhaps you've declared it as NSInteger *Player1Visits;
or int *Player1Visits;
.
If you declared it that way, remove the *
.
Upvotes: 3
Reputation: 60110
I would double-check what Player1Visits is declared as; if you're getting that compiler warning, it is almost certainly not an int
. Likely possibilities include what @aronchick said, where Player1Visits is an int*
(a pointer to an int), so you want to compare using:
*Player1Visits == 1
Another possibility is that Player1Visits is some kind of object with an int
property, where you want to figure out what property name you want and call:
[Player1Visits someIntProperty] == 1
(This last assumes you're using Objective-C, which is (I believe) a not-unreasonable assumption given your choice of IDE.)
Upvotes: 4