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]