Can I put different types of objects in the same NSMutableArray?

后端 未结 3 760
别那么骄傲
别那么骄傲 2021-02-14 00:19

I have classes A and B.
Can I put these classes in the same NSMutableArray without problems in future?

Example:

NSMutableArray *maincoll = [[NSMutabl         


        
3条回答
  •  野的像风
    2021-02-14 01:24

    Yes. No limitations. The only thing you have to be careful of is when you retrieve items from the array to verify their class (if necessary) before starting to use them.

提交回复
热议问题