I have the property:
@property(nonatomic, strong) IBOutletCollection(UIView) NSMutableArray *allOpposition;
which is wired up in IB to a bunch of subviews and synthesized. Later I have:
- (void)willRemoveSubview:(UIView *)subview
{
[[self allOpposition] removeObject:subview]; // Crash occurs here.
[super willRemoveSubview:subview];
}
When the time comes to remove the view representing an opposing entity, I get the following error message:
-[__NSArrayI removeObject:]: unrecognized selector sent to instance 0x88211c0
The object is not nil
and is contained in the collection. How come my array is immutable?
Remark: Quite possibly Apple requires each object in the collection to be of type UIView
, in this case. If the array were fully mutable conceivably I could add foreign types. I haven't found much documentation here so this is speculation on my part.
Remark: I don't see the value of allowing a mutable array to be passed in if the returned array is ultimately immutable. Why not just accept immutable arrays?