If I have a custom NSObject called Human which has a subclass called Male and I have an array called humans containing Human objects. When iterating over the humans array can I cast the object such as:
for (Human *human in humans) {
Male *male = (Male *)human;
}
or is it better to create a method to initWithMale such as
for (Human *human in humans) {
Male *male = [[Male alloc] initWithMale:(Male *)human];
}
What would be the best approach from a memory management point of view or would it not matter? If it is the latter then how would I manage this in my initWithMale method?
Thanks