Can I make a NSMutableArray
instance where all the elements are of type SomeClass
?
Nobody's put this up here yet, so I'll do it!
Tthis is now officially supported in Objective-C. As of Xcode 7, you can use the following syntax:
NSArray<MyClass *> *myArray = @[[MyClass new], [MyClass new]];
Note
It's important to note that these are compiler warnings only and you can technically still insert any object into your array. There are scripts available that turn all warnings into errors which would prevent building.