First, never override +(portfolio *) alloc
.
Second, init methods must call another init method and you must always check self
for nil
before setting ivars. Apple recommends against using properties to set ivars in init methods and init methods should always return instancetype
in compilers that support it or id
in those that don't.
-(instancetype) init
{
self = [super init];
if (self)
{
_stocks = [[NSMutableArray alloc] init];
}
return self;
}