4

When using this

NSInteger *myInteger = 45 ; 

I get the warning message Incompatible Integer to pointer conversion sending 'NSInteger' (aka 'int') to parameter of type 'NSInteger *' (aka 'int *') I have read another posts with same warning but did not find proper solution.

shirjai
  • 243
  • 2
  • 5
  • 20
  • 6
    You can't name a variable `int`, it's reserved... – rebello95 Oct 20 '14 at 07:37
  • replace *int with some variable name such as a,x, or any other which you want – iYoung Oct 20 '14 at 07:59
  • yeah .. i realized it later .. didnt give much attention to the variable name while posting the question. was more focused on the warning generated. have corrected it avoid any confusion – shirjai Oct 20 '14 at 08:33

2 Answers2

6

NSInteger is not a subclass of NSObject as it might seem, it's a primitive type. Change your code to:

NSInteger a = 45 ; 

And (of course) do not name your variable int

Andrey Chernukha
  • 21,488
  • 17
  • 97
  • 161
1

You should use different name then int because it is a name for a special primitive type integer. Like that you cannot name a variable with names like for, while, void... Just use another name(and you should name it to understand what it holds) like:

NSInteger myFirstInteger = 45;    

Note: In your future projects, please name your variables with a meaningful name ,so that you can create a meaningful piece of code which is easy to understand and improve.

Ersin Sezgin
  • 640
  • 5
  • 15