Chapter 2

#import “BNRItem.h”

@implementation BNRItem

  • (instancetype)initwithItemName:(NSString *)name valueInDollars:(int)value serialNumber:(NSString *)sNumber
    {
    [color=#FF40BF]self = [super init];[/color] there is a error here which indicates "Cannot assign ‘self’ outside of a method in the init family"
    if (self) {
    _itemName = name;
    _serialNumber = sNumber;
    _valueInDollars = value;
    _dateCreated = [[NSDate alloc] init];
    }
    return self;
    }

Is there anyone meet the same error?
Could you tell me what does this mean?

[quote]- (instancetype)initwithItemName:(NSString *)name valueInDollars:(int)value serialNumber:(NSString *)sNumber [/quote]
That’s an unorthodox name for an init-family method.

You probably wanted to write this:

- (instancetype)initWithItemName:(NSString *)name valueInDollars:(int)value serialNumber:(NSString *)sNumber
but forgot about camel casing.

The name of an init-family method needs to be camel cased correctly.