Lucas Veiga
Lucas Veiga

Reputation: 1795

OBJC: incompatible types in initialization

Hey gusys, why im getting this error?

The code is this. Im receiving a string on my function (a string like this "1799.00");

-(void) priceFormat:(NSString*)preco {

float x = preco; /* Incompatible types in initialization */

   if(x > 0) {
   }
}

Upvotes: 0

Views: 111

Answers (1)

MHC
MHC

Reputation: 6405

float x = [preco floatValue];

You have to convert the string to a floating-point value.

Upvotes: 2

Related Questions