0

can anyone help me i am setting um pushwoosh and i am getting this error

/PushNotificationManager.m:43:111: Implicit conversion loses integer precision: 'NSInteger' (aka 'long') to 'int'

rmaddy
  • 314,917
  • 42
  • 532
  • 579
user3244096
  • 21
  • 1
  • 3

1 Answers1

4

NSInteger has a larger size (equals long) on 64bit systems than int. The warning tells you, that you may loose information when transforming an NSIntegerto int. You can suppress the warning by typecasting to (int), but then you may suddenly find strange calculations due to the precision loss. Better to use NSIntegerinstead of int for all integer variables. See also When to use NSInteger vs. int for some more discussion.

Implicit vs. explicit:

NSInteger myLong = 11234;
int myInt = myLong; // implicit
int myInt2 = (int)myLong; // explicit by typecasting; you should know why you do this.
Community
  • 1
  • 1
Volker
  • 4,640
  • 1
  • 23
  • 31
  • can anyone connect to my mac via teamviever i am not sure how to do this? my Skype is: elvarpall – user3244096 Feb 03 '14 at 15:49
  • you are not sure how you can change a variable from int to NSInteger? Just go to the line Xcode gives you the warning for. And if necessary, typecast. – Volker Feb 03 '14 at 16:02
  • PushNotificationManager.m is the file you are looking for. You can go to the location in file by clicking the warning in the warnings list in Xcode.... – Volker Feb 03 '14 at 16:10
  • this is the line with the error return [NSMutableDictionary dictionaryWithObjectsAndKeys:@"increment", @"operation", [NSNumber numberWithInt:delta], @"value", nil]; } – user3244096 Feb 03 '14 at 16:13
  • replace [NSNumber numberWithInt:delta] with [NSNumber numberWithInteger:delta] – Volker Feb 03 '14 at 16:21
  • thank from 22 to 14 errors it coms new errors when i did that – user3244096 Feb 03 '14 at 16:36
  • i really would like if someone can connect to my Mac and take a look at my Xcode app via team viewer my Skype is: elvarpall – user3244096 Feb 03 '14 at 16:38