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.
Objective-C でプライベート メソッドを作成したい場合、何を使用すればよいですか? 1) よく知られているカテゴリ手法。 2) @private ディレクティブ。 (私はiOS開発を行っています)。
@private はメソッド用ではなく、ivar 用です。.m ファイルの先頭にクラス拡張を作成し、そこにプライベート メソッドを配置するだけです。それは何かのように見えます
@interface MyClass () // note the empty parens - (void)onePrivateMethod; - (void)twoPrivateMethod; @end @implementation MyClass // implement everything @end