I want to create a method that can take an NSMutableArray or an NSArray object.
I think I can just use (id) as the parameter type… or convert the NSArray to NSMutableArray before passing. However I’m not really happy with these solutions.
In other languages I might pass an IList or some shared object that they both inherit from…
I need to enumerate through the array in my method.
What is the way people would typically do this in objective c?
Take
NSArray.NSMutableArrayderives fromNSArray, so as long as you’re only using theNSArraymembers (such as read-only enumeration), you’ll be safe.Relevant documentation (from Apple’s developer site):