简体   繁体   中英

Implicit conversion loses integer precision: 'NSInteger' (aka 'long') to 'int'

I'm trying to build a project to distribute this app. But - this application, is too old from far. So, i'm using Xcode 8.3.3 and IOS Sierra.

Instead of this i'm having the problem SistemaCardapio/SistemaCardapioAppDelegate.m:60:28: Implicit conversion loses integer precision: 'NSInteger' (aka 'long') to 'int'

ARC - Desactivated for all build items needed.

I've tried to work on it, doing hand to hand, but is too many items to fix.

int timeOutParaImpressao = 0;
timeOutParaImpressao = [preferencias integerForKey:@"timeout_impressao"];
if (timeOutParaImpressao == 0) {
    NSLog(@"sem timeout pra impressao definido");
    timeOutParaImpressao = 20;
    [preferencias setInteger:timeOutParaImpressao forKey:@"timeout_impressao"];
}
configuracoes.timeOutImpressao = timeOutParaImpressao;

I Would like to remove this warnings, and compile the project on Xcode.

The warning is pretty clear: timeOutParaImpressao is declared as int which is a 32 bit integer and integerForKey returns a 64 bit integer on 64 bit machines.

Solution: Declare timeOutParaImpressao as NSInteger

NSInteger timeOutParaImpressao = 0;

Take warnings seriously and fix them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM