Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8970107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:41:09+00:00 2026-06-15T17:41:09+00:00

I am making a currency converter app and I’m having some issues with the

  • 0

I am making a currency converter app and I’m having some issues with the storage of the latest exchange rates. I have a method called applicationDidUpdateCurrency which can be called manually from within the app using a button, or when the app starts by clicking yes to an alert. The method gets the latest exchange rates and adds them to an array. I then have the app loop through a series of statements where the items from the NSArray are moved over to a float value and then logged to the console. All of that works fine.

+(void)applicationDidUpdateCurrency
{
    NSError *error;

    // Load .csv file. 

    NSString *allStates = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://download.finance.yahoo.com/d/quotes.csv?s=USDUSD=X,CNYUSD=X,GBPUSD=X,EGPUSD=X,CADUSD=X,EURUSD=X,&f=sl1d1t1ban&e=.csv"] encoding:NSUTF8StringEncoding error:&error];

    // Remove all quotes from file, replace them with nothing. 

    NSString *strippedPartOne = [allStates stringByReplacingOccurrencesOfString:@"\"" withString:@""];

    // Remove excess new lines from the csv file. 

    NSString *strippedPartTwo = [strippedPartOne stringByReplacingOccurrencesOfString:@"\r" withString:@""];

    // Add strippedPartTwo to array. 

    NSArray *rows = [strippedPartTwo componentsSeparatedByString:@"\n"];


    //   NSArray *components;

    for(int i=0; i<[rows count]; i++)
    {        
        components = [[rows objectAtIndex:i] componentsSeparatedByString:@","];

        // NSLog(@"Conversion: %@ Value: %@", [components objectAtIndex:0], [components objectAtIndex:1]);


        if ([[rows objectAtIndex:i] isEqualToString:@""]) {
            continue;
        }

        if (i==0) {
            float floatUSD = 1;

            NSLog(@"USD2: %f", floatUSD);
            continue;
        }

        if (i==1) {  
            float beforeFloatCNY = [[components objectAtIndex:1] floatValue];
            float floatCNY = 1 / beforeFloatCNY;
            NSLog(@"CNY2: %f", floatCNY);
        }

        if (i==2) {  
            float beforeFloatGBP = [[components objectAtIndex:1] floatValue];
            float floatGBP = 1 / beforeFloatGBP;
            NSLog(@"GBP2: %f", floatGBP);
        }

        if (i==3) {  
            float beforeFloatEGP = [[components objectAtIndex:1] floatValue];
            float floatEGP = 1 / beforeFloatEGP;
            NSLog(@"EGP2: %f", floatEGP);
        }

        if (i==4) {  
            float beforeFloatCAD = [[components objectAtIndex:1] floatValue];
            float floatCAD = 1 / beforeFloatCAD;
            NSLog(@"CAD2: %f", floatCAD);
        }

        if (i==5) {
            float beforeFloatEUR = [[components objectAtIndex:1] floatValue];
            float floatEUR = 1 / beforeFloatEUR;
            NSLog(@"EUR2: %f", floatEUR);
        }



    }

}

This method is in the same file that is associated with a table view controller which has a list of the currencies. I am simply trying to put those values back into that array so that they can more easily be sent back to the main view controller with a delegate.

After the applicationDidUpdateCurrency method has been called I can’t seem to a simple NSLog(@”USD2: %f”, floatUSD); to display that value again. It logs correctly right after it is defined, but even after the next if statement it just shows as 0.000000.

I declare the floatX values in the.h file using this code.

@property (nonatomic, assign) float floatUSD;

Could anyone help me out with this? I’m simply trying to define a float value, put it into an array, and send it back to the main view controller when the item is selected in the table view controller.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:41:10+00:00Added an answer on June 15, 2026 at 5:41 pm

    Because you’re re-declaring the variables and the newly declared variable (now in the innermost scope) hides the instance variable. (If you compiled this with warnings turned on, you would get some warnings about this). You don’t need, and in fact you should not re-declare these.

    Furthermore, access the property itself, and not the backing instance variable. So, all in all, instead of

    float floatUSD = 1;
    

    write

    self.floatUSD = 1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im having trouble working out making a converter for mutliple currencys using multiple subs.
I'm currently making an application for WP7 where I'm implementing a currency exchange solution.
I have been playing around with the currency converter web service offered by http://webservicex.net
I have an app that may save some files. When the user closes the
Hello Android programmers, I am making a currency application and to do this, I
Making a word document of our network set-up. We have about 7 servers and
Possible Duplicate: How to implement exchange rate in PHP? Im currently making a REST
I have a viewmodel where the properties have display names. I am now making
making a multi-language site with codeginiter. I have created two folders. One for french
I am making a simple currency convertor which takes the initial value in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.