Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
试图转换 objectAtIndex 的返回值。
(MyClass *)[myArray objectAtIndex:1].name;
你可以在 Objective-C 中像这样内联吗?
是的你可以:
((MyClass *)[myArray objectAtIndex:1]).name
您可以通过用常规方法调用语法替换访问属性的点语法来完全避免强制转换:
[[myArray objectAtIndex:1] name]