Trying to cast the return of objectAtIndex.
(MyClass *)[myArray objectAtIndex:1].name;
Can you cast inline like this in Objective-C?
You can avoid casting altogether by replacing the dot-syntax of accessing properties with the regular method invocation syntax:
[[myArray objectAtIndex:1] name]
name from MyClass you will continue to get a warning, but your app will crash and the code is hard to maintain this way...name does not correspond to a selector supported by any @interface in the system, an error is triggered. This approach works beautifully most of the time, and is a small price to pay for avoiding the need to provide an explicit cast.