Strictly answering your question, no.
There is no language support for specifying the parametric type of a collection, i.e. something like NSArray<MyClass> .
However, you can find workarounds to avoid explicit casts.
Since the returned object is of type id , you can call any existing method on it, and the compiler will not raise an eyebrow if you do not use point-syntactic notation, which has more stringent compiler checks.
So for example
NSString * name = [people[0] firstName];
works flawlessly without casting, whereas
NSString * name = people[0].firstName;
not.
source share