Video Tutorial: Objective-C Properties

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

Leave a rating/review
Save for later
Share

Contents

Hide contents

Video Tutorial: Objective-C Properties

0 mins

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

Over 300 content creators. Join our team.