Silver Challenge Solution


#1

Saw this wasn’t in here. Here’s the solution I came up with for creation of another initializer method of BNRItem.

-(instancetype)initWithItemName:(NSString *)name serialNumber:(NSString *)sNumber;

-(instancetype)initWithItemName:(NSString *)name serialNumber:(NSString *)sNumber { return [self initWithItemName:name serialNumber:@" "]; }


#2

Have you tested this new method after you added it? The sNumber parameter being passed in isn’t being used (@" " is being used instead). Also, this looks like a recursive method call to me, because initWithItemName:serialNumber: is calling itself. Here’s an example that resolves both of those issues:

- (instancetype)initWithItemName:(NSString *)name serialNumber:(NSString *)sNumber
{
    return [self initWithItemName:name serialNumber:sNumber valueInDollars:0];
}