Multiple initializers

Create a new file: a subclass of BNRAppliance named BNROwnedAppliance. In BNROwnedAppliance.h, add a mutable set of owner names and three methods.

#import "BNRAppliance.h"

@interface BNROwnedAppliance : BNRAppliance 
@property (readonly) NSSet *ownerNames;
- (instancetype)initWithProductName:(NSString *)pn
                     firstOwnerName:(NSString *)n;
- (void)addOwnerName:(NSString *)n;
- (void)removeOwnerName:(NSString *)n;

@end

Notice that one of the methods that you have declared is an initializer that takes two arguments.

Implement the methods in BNROwnedAppliance.m:

#import "BNROwnedAppliance.h"

@interface BNROwnedAppliance ()
{
    NSMutableSet *_ownerNames;
}
@end

@implementation BNROwnedAppliance

- (instancetype)initWithProductName:(NSString ...

Get Objective-C Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.