-[MyClassName copyWithZone:] unrecognized selector sent to instance

后端 未结 2 511
星月不相逢
星月不相逢 2021-02-01 01:02

My application crashed with the reason:

-[MyClassName copyWithZone:] unrecognized selector sent to instance

I have two classes. Let

2条回答
  •  不思量自难忘°
    2021-02-01 01:16

    Your -setObj1: method is declared as copy, so it calls -copy on your Class1 object. -copy just calls -copyWithZone:nil. So you either need to implement the NSCopying protocol (which means implementing -copyWithZone:), or change your property from copy to retain.

提交回复
热议问题