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.