I have :
NSInteger dollarrow = [ValuesPicker selectedRowInComponent:kDollar];
NSString *dollar = [dollarlist objectAtIndex:dollarrow];
double converteddollar=0;
I want to do a for loop on this and get the value in double , I am trying this :
for(dollar=1;dollar<=99;dollar++)
{
converteddollar = converteddollar + 2;
}
Now the dollar contains NSString how do I convert into double to do the operation successfully and then
NSString *message = [[NSString alloc] initWithFormat:@"%0.2f",converteddollar];
I am getting warnings and the app is crashing .. How can I correct it .
I am learning Objective C please help .
Thankyou .
Sorry I did not want == i just wanted to use =
Your for loop is wrong. Are you really want ‘==’? I guess you want only ‘=’. Can’t you use something like this? (I’m just giving an example to point the mistakes in loop. Your requirement may be something different. And also I have not compiled the code, don’t have mac with me right now. So you may get some minor mistake)
double sum = 0 for (NSInteger i = 1; i <= 99; i++) { sum += 2; // or whatever you need here } NSString *convertedStr = [NSString stringWithFormat:@"%lf", sum];