Silver Challenge BNRItem semantic issue


#1

Hi guys,
How come this code is dodgy as it constantly gives me semantic issues within the *.m file.
It keeps responding with "method definition for SerialNumber and setSerialNumber not found."
Unfortunately I can’t highlight it, if you need the *.h file code I can also post it here.

@implementation BNRItem
- (instancetype) initWithItemName:(NSString *)name valueInDollars:(int)value serialNumber:(NSString *)sNumber
{
    // Call the superclass's designated initialiser
    self = [super init];
    
    // Did the superclass's designated initaliser succeed?
    if (self) {
        // Give the instance variable initial values
        _itemName = name;
        _serialNumber = sNumber;
        _valueInDollars = value;
        // Set the '_dateCreated' implimentation to the current time and time of the system clock
        _dateCreated = [[NSDate alloc] init];
    }
    // Return the address of the newly initialised object
    return self;
}

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

- (NSString *)description
{
    NSString *descriptionString = [[NSString alloc] initWithFormat:@"\nItem:%@ \nSerial number:%@", self.itemName, self.serialNumber];
    return descriptionString;
}

- (void)setItemName:(NSString *)str
{
    _itemName = str;
}

- (NSString *)itemName
{
    return _itemName;
}

- (void)setValueInDollars:(int)v
{
    _valueInDollars = v;
}

- (int)valueInDollars
{
    return _valueInDollars;
}

- (NSDate *)dateCreated
{
    return _dateCreated;
}
@end

#2

Is that the exact msg? I ask because for starters it means you have a typo somewhere, trying to reference the getter via [color=#FF0000]S[/color]erialNumber instead of via [color=#FF0000]s[/color]erialNumber.

Whereever that other source file is (not BNRItem.h but some other .m file), it’s apparently trying to get and set the serial number…but if you read through the code you posted, you’ll see that it doesn’t define either a getter or a setter method for the serial number.


#3

ironically it was was in the BNRItem.h file just need to read carefully and keep rebuilding.