Silver Challenge solution


This is how I worked out the Silver Challenge, can anyone indicate if it’s right? (since I see some solutions here who treat the initializer as a designated initializer)


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


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

Thanks in advance!


Can anyone confirm that this is the correct way? :wink:


I’m confused. Do you have two initializers with the same name?

It looks like you are calling the original initWithItemName method that had 3 parameters, but you are calling it with a new initializer that has 2 parameters and is using the same name…


Yep, I did it basically the same way it is explained on page 51 in the book (if I interpreted it right :confused: )


Pippah: Yes, your solution is correct. You can verify that it works correctly by actually calling it, for example, from RandomPossessions main.m.