在NSArray上转换objectAtIndex的返回值

jdo*_*dog 4 casting objective-c nsarray ios

试图转换objectAtIndex的返回.

(MyClass *)[myArray objectAtIndex:1].name;
Run Code Online (Sandbox Code Playgroud)

你能在Objective-C中像这样投射内联吗?

gra*_*ver 11

是的你可以:

((MyClass *)[myArray objectAtIndex:1]).name
Run Code Online (Sandbox Code Playgroud)