I have a singleton class with a NSMutableArray property to which I want to add objects and remove objects. For some reason I am getting:
-[__NSDictionaryI s
Your
@property (nonatomic, copy) NSMutableDictionary *p_outbox;
is creating a copy of that object which you assign to it.
As you are assigning a NSMutableDictionary
to it, it's creates a copy of NSMutableDictionary
object which is NSDictionary
which is not a mutable copy.
So change it to
For Non ARC
@property (nonatomic, retain) NSMutableDictionary *p_outbox;
For ARC
@property (nonatomic, strong) NSMutableDictionary *p_outbox;
The problem is with your property:
@property (nonatomic, copy) NSMutableDictionary *p_outbox;
The copy
semantics of the property result in a copy of the dictionary being made when you assign a value to the property. But the copy
method for a dictionary always returns an immutable NSDictionary
, even when called on an NSMutableDictionary
.
To solve this problem you must create your own setter method for the property:
// I'm a little unclear what the actual name of the method will be.
// It's unusual to use underscores in property names. CamelCase is the standard.
- (void)setP_outbox:(NSMutableDictionary *)dictionary {
p_outbox = [dictionary mutableCopy];
}