MyItem *item = ...
This local variable forms a strong reference. If initWithParam:
returns an object (not nil), there'w no way it can be deallocated before being added to the list (which creates another strong reference).
Please take note that your property declaration is flawed:
@property (nonatomic, copy) NSMutableArray *itemsList;
The copy
attribute does not go well with a mutable object type: When the property is assigned, the synthesized setter calls copy
on it, which creates an immutable copy of the array and assigns that. This contradicts the type of the property.
Here's in fact a nice opportunity for another helpful clang compiler warning: Properties cannot be declared copy
when their type conforms to NSMutableCopying
. clang team, are you hearing?.