Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在NSArray, NSMutuableArray,... 数据类型,addobject:方法中,我可以将其大小设置为某个限制吗?
NSArray
NSMutuableArray
addobject:
您是否试图限制可以添加到 NSMutableArray 的元素数量?
如果是这样,那么您可以在添加新对象之前检查当前计数是否小于您想要的最大值:
if (someMutableArray.count < max) { [someMutableArray addObject:anObject]; };