ios - Convert NSString to NSInteger -
i have
nsstring *stramount = @"10.00"; nsinteger totalamount = totalamount + [stramount integervalue];
the output is
totalamount = 80
but want output totalamount = 10
- first of
totalamount
should not of pointer type. - variable '
totalamount
' uninitialized when used within own initialization
replace code with
nsstring *stramount = @"10.00"; nsinteger totalamount = 0; totalamount = totalamount + [stramount integervalue]; nslog(@" %ld",(long)totalamount);
output = 10
Comments
Post a Comment