Unrecognized selector when adding an object to NSMutableArray

前端 未结 2 1563
情深已故
情深已故 2020-12-21 21:14

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         


        
2条回答
  •  北荒
    北荒 (楼主)
    2020-12-21 21:24

    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;
    

提交回复
热议问题