Video Tutorial: Objective-C Initializers

The first video in our Objective-C series. Learn how to create your own custom initializers in Objective-C classes: the right way. By Ray Wenderlich.

Leave a rating/review
Save for later
Share

Contents

Hide contents

Video Tutorial: Objective-C Initializers

0 mins

Challenge

Your challenge is to add a custom initializer to your TemperatureConverter class from the last video tutorial, so that this line of code works:

TemperatureConverter *converter = [[TemperatureConverter alloc] initWithLocation:@"Virginia"];

Download demo code

Download challenge starter project

Download solution

Helpful links

Errata

  • When I explained why I used variables instead of properties in the init method, I mentioned the gotcha of accidentally adding side effects if they provided implementations of those methods. However, another potential gotcha I didn’t mention is if someone subclasses your class, overrides the setter for your property, and adds a side effect, you have the same problem.

Contributors

Over 300 content creators. Join our team.