0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Objectice-Cでのinitではまった

0
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?