Last Chance: RW Accelerator Bootcamps

Bootcamps start August 15th — Don't miss out!
Save 50% and go from novice coder to job-ready mobile developer in just 12 weeks.

Home

Video Tutorial: Objective-C Properties

Learn how properties work in Objective-C: a core topic that is essential to understand as an iOS developer.

Challenge

Your challenge is to add two new properties to your TemperatureConverter class from the last video tutorial:

  • location: A string that stores the location of the temperature readings
  • averageDegreesFarenheit: The average of the values passed to degreesFarenheitToCelsius so far

Inside your App Delegate, replace the application:didFinishLaunchingWithOptions: method with this to test it:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    TemperatureConverter *converter = [[TemperatureConverter alloc] init];
    converter.location = @"Virginia";
    
    for (int i = 60; i <= 80; i+= 10) {
        float degreesCelsius = [converter degreesFarenheitToCelsius:i];
        NSLog(@"%0.2f degrees farenheit = %0.2f degrees celsius",
            (float)i, degreesCelsius);
    }
    
    NSLog(@"Average degrees farenheit in %@: %0.2f", converter.location, converter.averageDegreesFarenheit);
    
    return YES;
}

Download demo code

Download challenge starter project

Download solution

Helpful links

Contributors

Comments

Reviews

More like this