Silver challenge: what to do with date created


#1

This is my solution.

  • I wanted date created zeroed out, as the challenge asked for init with only name and serial number.
  • Is this (stylishly) correct use of self? (self = [self … ]; return self; )

in BNRItem.m (declared in .h):

[code]//silver chall init

  • (id) initWithItemName:(NSString *)itsName
    serialNumber:(NSString *)itsSNr {

    self = [self initWithItemName:itsName
    valueInDollars:0
    serialNumber:itsSNr];
    dateCreated = nil;
    return self;
    }
    [/code]
    and in main.m:

//create instance with silver init:
   BNRItem *p= [[BNRItem alloc]initWithItemName:@"Champions Cup"
                                        serialNumber:@"UEFA2013"];
        [items addObject:p];
    
        for (BNRItem *item in items) {
            NSLog(@"%@", item);
        }

output:
2013-08-13 23:19:00.392 BNR 1 RandomPossesions[87935:303] Champions Cup (UEFA2013): Worth $ 0, recorded on (null)