1

I am getting a warning implicit conversion loses integer precision

NSMutableArray *arr ;

int x = [arr count];

How to solve it ?

Illep
  • 16,375
  • 46
  • 171
  • 302
  • 1
    possible duplicate of [objective c implicit conversion loses integer precision 'NSUInteger' (aka 'unsigned long') to 'int' warning](http://stackoverflow.com/questions/16918826/objective-c-implicit-conversion-loses-integer-precision-nsuinteger-aka-unsig) – Vizllx May 22 '15 at 09:54
  • possible duplicate of [Warning: Implicit conversion loses Integer precision in xcode 6](http://stackoverflow.com/questions/25954180/warning-implicit-conversion-loses-integer-precision-in-xcode-6) – CRDave May 22 '15 at 10:05

1 Answers1

8

Change int to NSUInteger. it will solve your problem.

NSArray count is NSUInteger.

On 64-bit systems, NSUInteger and NSInteger are 64-bits but int is 32-bit. So the value won't fit which results in the warning.

If you want to ignore this type of warning you can update project settings, to remove all Implicit conversion loses integer precision warnings, by setting

Implicit Conversion to 32 Bit Type to No

enter image description here

Vijay Masiwal
  • 1,153
  • 8
  • 12