Can I restrict the NSMutableArray object type?

大城市里の小女人 提交于 2020-01-06 09:55:11

问题


I want the NSMutableArray only store "MyObject" only... ...instead of any objects. How can I do this? thz.


回答1:


There is no concept like C# Generics or C++ Templates in Objective-C, as discussed here before, but you could create a class which exposes an array and has add and remove-methods which take only your object type (see here).



来源:https://stackoverflow.com/questions/2690821/can-i-restrict-the-nsmutablearray-object-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!