LoginSignup
0
0

More than 5 years have passed since last update.

Objectice-Cでのinitではまった

Posted at

自前のObjectice-Cクラスを書くときにinitではまった。
当初下記のように書いた。

- (MyClass*)init:(double)paramA with:(double)paramB;

でもこれだとNo visible selectorってでる。
なんでかと思っていじっていると下記のように書いたらエラーが消えた。

- (MyClass*)initWithParamA:(double)paramA 
                    paramB:(double)paramB;

多分initメソッドとinit:with:は同じものとして見られるのだと思う。withはキーワードでしかないのでメソッドの名前を判断する上で必要とされているのはあくまでもinitのみなのではないだろうか。
なので自前でメソッドを作るときはキーワードでない先頭の名前を変更することが大事。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0